Merge pull request #206 from openclassify/basetheme

#205 fixed edit category for nullable ad
This commit is contained in:
Fatih Alp 2020-01-07 12:28:28 +03:00 committed by GitHub
commit 746cfd86ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 11 deletions

View File

@ -59,26 +59,28 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
return true;
}
public function getAdv($id = null)
public function getAdv($id = null, $nullable_ad = false)
{
if ($id != null) {
return AdvModel::query()
->where('advs_advs.slug', '!=', "")
->find($id);
if ($nullable_ad)
return $this->find($id);
else
$this->where('advs_advs.slug', '!=', "")
->find($id);
}
return AdvModel::query()
->where('advs_advs.slug', '!=', "");
if ($nullable_ad)
return $this->newQuery();
return $this->where('advs_advs.slug', '!=', "");
}
public function userAdv()
public function userAdv($nullable_ad = false)
{
if (Auth::user()->hasRole('admin')) {
return $this->getAdv();
return $this->getAdv(null, $nullable_ad);
} else {
return $this->getAdv()
return $this->getAdv(null, $nullable_ad)
->where('advs_advs.created_by_id', Auth::id());
}
}
public function getAdvByCat($cat_id)

View File

@ -789,7 +789,7 @@ class AdvsController extends PublicController
redirect('/login?redirect=' . url()->current())->send();
}
$is_ad = $this->adv_model->userAdv($id)->find($id);
$is_ad = $this->adv_model->userAdv(true)->find($id);
if (is_null($is_ad)) {
abort(403);