mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
#2336 redirect ad detail link if slug is different
This commit is contained in:
parent
ff9808689b
commit
9b9157d8b4
@ -218,13 +218,11 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
|
||||
{
|
||||
if ($type != null) {
|
||||
$id = $object->id;
|
||||
$seo = str_slug($object->name);
|
||||
$seo = str_replace('_', '-', $seo);
|
||||
$seo = str_slug($object->slug, '-');
|
||||
return \route('adv_detail_seo', [$seo, $id]);
|
||||
}
|
||||
$id = $object->getObject()->id;
|
||||
$seo = str_slug($object->getObject()->name);
|
||||
$seo = str_replace('_', '-', $seo);
|
||||
$seo = str_slug($object->getObject()->name, '-');
|
||||
return \route('adv_detail_seo', [$seo, $id]);
|
||||
}
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Cookie;
|
||||
use Illuminate\Support\Str;
|
||||
use Visiosoft\AdvsModule\Adv\AdvModel;
|
||||
use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
|
||||
use Visiosoft\AdvsModule\Adv\Event\ChangedStatusAd;
|
||||
@ -579,12 +580,16 @@ class AdvsController extends PublicController
|
||||
|
||||
$configurations = $this->optionConfigurationRepository->getConf($adv->id);
|
||||
|
||||
if ($adv->created_by_id == isset(auth()->user()->id) or $adv->status == "approved") {
|
||||
return $this->view->make('visiosoft.module.advs::ad-detail/detail', compact('adv', 'complaints',
|
||||
'recommended_advs', 'categories', 'features', 'options', 'configurations'));
|
||||
} else {
|
||||
return back();
|
||||
}
|
||||
|
||||
if (Str::slug($adv->slug, '-') != $seo) {
|
||||
$this->messages->error(trans('visiosoft.module.advs::message.ad_doesnt_exist'));
|
||||
return redirect()->route('visiosoft.module.advs::list');
|
||||
} else if ($adv->created_by_id == isset(auth()->user()->id) or $adv->status == "approved") {
|
||||
return $this->view->make('visiosoft.module.advs::ad-detail/detail', compact('adv', 'complaints',
|
||||
'recommended_advs', 'categories', 'features', 'options', 'configurations'));
|
||||
} else {
|
||||
return back();
|
||||
}
|
||||
} else {
|
||||
$this->messages->error(trans('visiosoft.module.advs::message.ad_doesnt_exist'));
|
||||
return redirect()->route('visiosoft.module.advs::list');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user