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; return true;
} }
public function getAdv($id = null) public function getAdv($id = null, $nullable_ad = false)
{ {
if ($id != null) { if ($id != null) {
return AdvModel::query() if ($nullable_ad)
->where('advs_advs.slug', '!=', "") return $this->find($id);
->find($id); else
$this->where('advs_advs.slug', '!=', "")
->find($id);
} }
return AdvModel::query() if ($nullable_ad)
->where('advs_advs.slug', '!=', ""); return $this->newQuery();
return $this->where('advs_advs.slug', '!=', "");
} }
public function userAdv() public function userAdv($nullable_ad = false)
{ {
if (Auth::user()->hasRole('admin')) { if (Auth::user()->hasRole('admin')) {
return $this->getAdv(); return $this->getAdv(null, $nullable_ad);
} else { } else {
return $this->getAdv() return $this->getAdv(null, $nullable_ad)
->where('advs_advs.created_by_id', Auth::id()); ->where('advs_advs.created_by_id', Auth::id());
} }
} }
public function getAdvByCat($cat_id) public function getAdvByCat($cat_id)

View File

@ -789,7 +789,7 @@ class AdvsController extends PublicController
redirect('/login?redirect=' . url()->current())->send(); 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)) { if (is_null($is_ad)) {
abort(403); abort(403);