I've these tables:
Users
|id|role_id|clan_id|
Roles
|id|slug|
Clans
|id|
I need to grab all Users where slug is for example 'leader'
How can I do it?
What I got so far:
class clan extends Model{
public function leader()
{
$leader = User::whereHas('role', function($query) {
$query->where('slug', 'leader');
})->where('clan_id', $this->id)->get();
return $leader;
}
}
But this wouldn't be smart. Instead of this I would like to have it joined my clans table
Clans:
|id|leader_user_id|
so I can access it easily.
Thanks alot :)