Merge pull request #154 from openclassify/dia

Improvements of SEO link structure like Vebze #74
This commit is contained in:
Fatih Alp 2019-11-21 10:08:05 +03:00 committed by GitHub
commit fb7f802d81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 6 deletions

View File

@ -228,12 +228,12 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
$id = $object->id;
$seo = str_slug($object->name);
$seo = str_replace('_', '-', $seo);
return \route('adv_detail_seo', [$id, $seo]);
return \route('adv_detail_seo', [$seo, $id]);
}
$id = $object->getObject()->id;
$seo = str_slug($object->getObject()->name);
$seo = str_replace('_', '-', $seo);
return \route('adv_detail_seo', [$id, $seo]);
return \route('adv_detail_seo', [$seo, $id]);
}
public function getAdvDetailLinkByAdId($id)
@ -243,7 +243,7 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
$id = $adv->id;
$seo = str_slug($adv->name);
$seo = str_replace('_', '-', $seo);
return \route('adv_detail_seo', [$id, $seo]);
return \route('adv_detail_seo', [$seo, $id]);
}
}

View File

@ -118,12 +118,20 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
'as' => 'adv_detail_seo',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@view'
],
'ad/{id}' => [
'as' => 'adv_detail',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@view'
],
'ad/{seo}/{id}' => [
'as' => 'adv_detail_seo',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@view'
],
'advs/map?country={country}&city[]={city}&district={districts}' => [
'as' => 'visiosoft.module.advs::show_ad_map_location',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@map'
],
'advs/categories' => 'Visiosoft\AdvsModule\Http\Controller\CategoriesController@index',
'advs/categories/{cat}' => 'Visiosoft\AdvsModule\Http\Controller\CategoriesController@listByCat',
'advs/c/{cat}' => 'Visiosoft\AdvsModule\Http\Controller\CategoriesController@listByCat',
'advs/module_active' => 'Visiosoft\AdvsModule\Http\Controller\advsController@index',
'advs/create_adv' => [
'as' => "create_adv",

View File

@ -8,12 +8,24 @@ class CategoriesController extends PublicController {
public function listByCat($cat) {
$advs = DB::table('advs_advs')
->where('category_id', $cat)
->where('cat1', $cat)
->orwhere('cat2', $cat)
->orwhere('cat3', $cat)
->orwhere('cat4', $cat)
->orwhere('cat5', $cat)
->orwhere('cat6', $cat)
->orwhere('cat7', $cat)
->leftJoin('users_users as u1', 'advs_advs.created_by_id', '=', 'u1.id')
->leftJoin('advs_advs_translations as t1', 'advs_advs.id', '=', 't1.id')
->select('advs_advs.*','u1.username as owner', 't1.name as name')
->get();
foreach ($advs as $adv) {
if (strpos($adv->cover_photo, 'http') !== 0 && strpos($adv->cover_photo, '/') !== 0) {
$adv->cover_photo = "/$adv->cover_photo";
}
}
return $this->view->make('visiosoft.module.advs::list/list', compact('advs'));
}
}

View File

@ -245,8 +245,10 @@ class AdvsController extends PublicController
return redirect($this->request->headers->get('referer'));
}
public function view($id)
public function view($seo, $id = null)
{
$id = is_null($id) ? $seo : $id;
$categories = array();
$categories_id = array();
$isActiveComplaints = $this->adv_model->is_enabled('complaints');