In my Laravel 8 project I have an existing global scope bind to a model like so:
protected static function booted() {
static::addGlobalScope(new CompanyScope());
}
I already know that you can add a local scope to a validation rule like this:
class ExpenseRequest extends FormRequest {
protected function validationRules(): array {
return [
"attachment" => Rule::exists('files')->where(function ($query) {
(new Expense())->scope($query);
})
];
}
}
I want to add the global scope to an "exists" rule, but didn't find anything about how to do this. Does somebody know how to do this?