get(); */ class PortalScope implements Scope { public function apply(Builder $builder, Model $model): void { $portal = CurrentPortalContext::get(); if ($portal === null) { return; } $table = $model->getTable(); $builder->where(function (Builder $q) use ($table, $portal): void { $q->where("{$table}.portal", $portal->value) ->orWhere("{$table}.portal", Portal::Both->value); }); } }