So, I have a "noms" relation in provider model, i want, if role is manager, to return all models from noms.
I have this:
{
return $this->hasMany(Nom::class);
}
want something like:
{
if($this->role === "manager"){
return Nom::all
}
return $this->hasMany(Nom::class);
}
2
Answers
The relationship:
It should be that way, no more, no less. Extra logics should be the responsibility of a different place, such as an action controller.
You could do something like this:
User model class:
Ps: don’t forget to import necessary models in User model class like Nom class.
Controller:
Why this approach?