I have the below tables
- users : id | name
- projects : id | name
- user_project : id | user_id | project_id
My Models contains
-
User.php
public function projects() { return $this->belongsToMany(Project::class); }
-
Project.php
public function users() { return $this->belongsToMany(User::class); }
In my controller file, I want to get a list of users using the User model whose role_id is 5.
Something like below
User::query()->roles(5);
*Help will be appreciated
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3muliUH
via IFTTT
Aucun commentaire:
Enregistrer un commentaire