I have users with different roles, like Admin,Employee,Secretary,etc.
And i have a page for send letter, in this page i have a select option
to show indicators.
I want when user with Secretary role open this page, see all of the indicators but other users with other roles just see one indicator like internal letters, how can i do this ?
I have a relation between role
and user
:
User Model
public function roles()
{
return $this->belongsToMany(Role::class);
}
Role Model
public function users()
{
return $this->belongsToMany(User::class);
}
This is select option
in send letter page :
<select class="col-12 border mt-2 pt-2" name="indicator_id">
@foreach($indicators as $indicator)
<option value=""></option>
@endforeach
</select>
As you can see, indicators comes from somewhere else.
This is Letter Controller to show send letter page :
$indicators = Indicator::all();
return view('Letter.add', compact('indicators'));
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire