Fix for BBS List

This commit is contained in:
Deon George 2023-04-22 21:31:09 +10:00
parent b1d522d8cc
commit 073be20ceb

View File

@ -17,16 +17,17 @@ class System extends Model
/**
* Only query active records
* @todo test false action
*/
public function scopeActive($query)
{
$uo = Auth::user();
return $query
->when(! $uo->isAdmin(),function($query) use ($uo) {
->when($uo && ! $uo->isAdmin(),function($query) use ($uo) {
return $query->whereIn('id',$uo->systems->pluck('id'))
->orWhere($this->getTable().'.active',TRUE);
})
},function($query) { $query->where($this->getTable().'.active',TRUE); })
->orderBy('name');
}