本文整理汇总了PHP中app\models\Permission::All方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::All方法的具体用法?PHP Permission::All怎么用?PHP Permission::All使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Permission
的用法示例。
在下文中一共展示了Permission::All方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$variables = Variable::All();
$permissions = Permission::All();
return view('variables.index')->withVariables($variables)->withPermissions($permissions);
}
示例2: getIndex
public function getIndex()
{
$users = User::All();
$permissions = Permission::All();
return view('admin.index')->withUsers($users)->withPermissions($permissions);
}
示例3: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($type)
{
$permissions = Permission::All();
return view('transtype.edit')->withType($type)->withPermissions($permissions);
}
示例4: grantPermission
/**
* Grant a permission to a user
*/
public function grantPermission(Request $request)
{
$user = User::find($request->get('user_id'));
if ($request->get('permission_id') == 'all') {
$permissions = Permission::All();
foreach ($permissions as $permission) {
if (!$user->permissions->contains($permission->id)) {
$user->permissions()->attach($permission);
if ($request->get('is_master')) {
$target = $user->permissions()->find($permission->id);
$target->pivot->is_master = true;
$target->pivot->save();
}
}
}
Flash::success('Gave ' . $user->name . ' all permissions.');
return redirect()->back();
}
$permission = Permission::find($request->get('permission_id'));
$user->permissions()->attach($permission);
if ($request->get('is_master')) {
$target = $user->permissions()->find($permission->id);
$target->pivot->is_master = true;
$target->pivot->save();
}
Flash::success('Gave ' . $user->name . ' permission:' . $permission->name);
return redirect()->back();
}