Skip to content

Instantly share code, notes, and snippets.

@DB-009
Last active August 29, 2015 14:07
Show Gist options
  • Save DB-009/72abec192853581bdc6d to your computer and use it in GitHub Desktop.
Save DB-009/72abec192853581bdc6d to your computer and use it in GitHub Desktop.
View::composer('*', function($view)
{
$role = UserPermission::where('user_role_id','=',Auth::user()->role_id)->select('permissions_data')->get();
$role->toArray();
// $replace = array('"','[',']');
//$data = str_replace($replace, "", $role->permissions_data);
//$permissions = explode(',',$data );
if($role){
$ret = json_encode($role);
// json_encode($ret[0]);
dd($ret);
}
else{
$ret= json_decode('["index"]');
}
$view->with('modules', SystemModule::orderBy('order','asc')->get())->with('childs', SystemModule::where('parent_id' , '!=' , 0)->orderBy('order','asc')->get())->with('permissions',$ret);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment