i have a user table :
and i have a realtion between user and roles :
role Model :
public function users()
{
return $this->belongsToMany(User::class);
}
user Model :
public function roles()
{
return $this->belongsToMany(Role::class);
}
and i have view for show users like this :
<select class="col-12 border mt-2 pt-2" name="reciever">
@foreach($users as $user)
<option value=""></option>
@endforeach
</select>
and this is controller :
$users = User::all();
return view('Form1.add', compact('users'));
but in view, i want to show just user with role Admin, how can i do this ?
this is role table :
and this is pivot table between user and role like this :
i just want to show user with Admin role.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire