Added moduleIsEnabled scope to Model.php
This commit is contained in:
parent
4c25459dd7
commit
0fceb96078
|
|
@ -246,6 +246,15 @@ abstract class Model extends Eloquent implements Ownable
|
|||
return $query->where($this->qualifyColumn('type'), 'not like', '%-recurring');
|
||||
}
|
||||
|
||||
public function scopeModuleEnabled(Builder $query, string $module): Builder
|
||||
{
|
||||
return $query->allCompanies()->whereHas('company', fn (Builder $q1) =>
|
||||
$q1->enabled()->whereHas('modules', fn (Builder $q2) =>
|
||||
$q2->allCompanies()->alias($module)->enabled(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function ownerKey($owner)
|
||||
{
|
||||
if ($this->isNotOwnable()) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue