vendredi 27 avril 2018

How to use same variable or query result in all the page in laravel

am using laravel 5.4, I want to use some query for all the page. Like I have one table to set permission for users. If users have permission then they will be able to get some extra menu. I have created a new page '_menu.blade.php'. This page is included to the all page. So, now what happening is, I have to check for all pages controller for users permission table and send those data. Suppose, I have home.blade.php. Here I have added menu.blade.php and then my controller for home.blade.php is

public function index(){
 $Permission  = Permission::where('edit',$currentUserId)->first();
return view('home')->withPermission($Permission);
}

And also I have read.blade.php. Here also I have added menu.blade.php and then my controller for read.blade.php is

public function index(){
 $Permission  = Permission::where('edit',$currentUserId)->first();
return view('read')->withPermission($Permission);
}

Here I have to fetch users permission for all the pages. Now What I want is, Just fetch user permission at once and use this permission in all the pages.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2JySk2Y
via IFTTT

Aucun commentaire:

Enregistrer un commentaire