How do I return all models in a relation

  Kiến thức lập trình

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);
     }

New contributor

DiNikSon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT