本文整理汇总了PHP中app\Permission::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::findOrFail方法的具体用法?PHP Permission::findOrFail怎么用?PHP Permission::findOrFail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Permission
的用法示例。
在下文中一共展示了Permission::findOrFail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @param \Illuminate\Http\Request $request
*
* @return void
*/
public function update($id, Request $request)
{
$this->validate($request, ['name' => 'required']);
$permission = Permission::findOrFail($id);
$permission->update($request->all());
Session::flash('flash_message', 'Permission updated!');
return redirect('admin/permissions');
}
示例2: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Request $request, $id)
{
$this->validate($request, ['name' => 'required|unique:permissions,id,' . $id . '|max:255', 'label' => 'required|unique:permissions,id,' . $id . '|max:255']);
$permission = Permission::findOrFail($id);
$permission->update($request->all());
flash()->success('Success!', 'Permission has been updated!');
return redirect('permissions');
}
示例3: update
/**
* do edit data
* @param mixed $request
* @param int $id
* @return redirect
*/
public function update(Request $request, $id)
{
$messages = ['name.required' => 'Permission name is necessary!'];
$this->validate($request, ['name' => 'required'], $messages);
$permission = Permission::findOrFail($id);
$permission->update($request->all());
return redirect(route('admin.permission.index'))->with('info', 'Updated Successfully~~');
}
示例4: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Request $request, $id)
{
if (!$this->user->userCan('permission-edit')) {
\App::abort(403, 'Access denied');
}
$permission_model = \App\Permission::findOrFail($id);
$permission_model->update($request->all());
return redirect('/admin/permission');
}
示例5: update
/**
* Update the specified resource in storage.
*
* @param \App\Http\Requests\EditPermissionRequest $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(EditPermissionRequest $request, $id)
{
$this->authorize('permissions-edit');
$permission = Permission::findOrFail($id);
$permission->update($request->all());
$roles = empty($request->roles) ? [] : $request->roles;
$permission->roles()->sync($roles);
return redirect('permissions');
}
示例6: editPermission
public function editPermission(Request $request)
{
$item = Permission::findOrFail($request->id);
$item->name = $request->name;
$item->display_name = $request->display_name;
$item->description = $request->description;
$item->save();
return \Response::make($item, 200);
}
示例7: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(PermissionRequest $request, $id)
{
//
$permission = Permission::findOrFail($id);
$permission->name = $request->input('name');
$permission->display_name = $request->input('display_name');
$permission->description = $request->input('description');
$permission->update();
return redirect('system/permissions');
}
示例8: update
public function update(Request $request, $id)
{
$permission = Permission::findOrFail($id);
$this->validate($request, ['name' => 'required|max:255', 'label' => 'required|max:255']);
$input = $request->all();
$permission->name = $request->name;
$permission->label = $request->label;
$permission->save();
Session::flash('flash_message', 'Permission updated!');
return redirect()->back();
}
示例9: hasPermission
public function hasPermission($permission)
{
$errors = array_filter($permission);
if (!empty($errors)) {
foreach ($values as $value) {
$permission = Permission::findOrFail($value);
$this->givePermissionTo($permission);
return !!$permission->intersect($this->permissions)->count();
}
}
}
示例10: addPermission
public function addPermission(Request $request, $id)
{
$this->validate($request, ['permission' => 'required']);
try {
$role = Role::findOrFail($id);
$permission = Permission::findOrFail($request->input('permission'));
$role->permissions()->save($permission);
\Session::flash('message-success', 'Permissão adicionada a role: ' . $role->name);
return redirect()->route('admin::roles::edit', $id);
} catch (Exception $e) {
return redirect()->route('admin::roles::list')->withErrors($e->getMessage());
}
}
示例11: edit
public function edit($id)
{
$permission = Permission::findOrFail($id);
return view('admin.permission.edit', compact('permission'));
}
示例12: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($roleId, $permissionId)
{
//
$role = Role::findOrFail($roleId);
$permission = Permission::findOrFail($permissionId);
if ($role != null && $permission != null) {
$role->detachPermission($permission);
} else {
back();
}
return redirect('system/roles/' . $roleId . '/permissions');
}
示例13: canInBoards
/**
* Returns a list of direct, extant Board URIs where this permission exists.
* The goal of this is to weed out loose permissions provided by global permissions.
*
* @return array (of board_uri)
*/
public function canInBoards($permission)
{
$boards = [];
if (!$permission instanceof Permission) {
$permission = Permission::findOrFail($permission);
}
$boardsWithRights = $permission->getBoardsWithPermissions($this, false);
$boards = [];
foreach ($boardsWithRights as $board_uri) {
if (is_null($board_uri) || strlen($board_uri) === 0) {
continue;
}
if ($this->getPermission($permission, $board_uri)) {
$boards[] = $board_uri;
}
}
return $boards;
}
示例14: findById
public function findById($id)
{
return \App\Permission::findOrFail($id);
}
示例15: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$permission = Permission::findOrFail($id);
$permission->delete();
return redirect(route('admin.permissions.index'))->with('success', 'The permission has been deleted.');
}