本文整理汇总了PHP中app\models\Permission::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::find方法的具体用法?PHP Permission::find怎么用?PHP Permission::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Permission
的用法示例。
在下文中一共展示了Permission::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
public function save(Request $request)
{
$as = $request->input('as');
$permission = new Permission();
$validator = \Validator::make($request->all(), $permission->getRules());
$results = new \StdClass();
if ($validator->passes()) {
if ($request->input('id') != "xxx") {
$permission = Permission::find($request->input('id'));
$permission->name = $request->input('name');
$permission->display_name = $request->input('displayname');
$permission->description = $request->input('description');
$permission->save();
$results->info = 'permission create';
} else {
$permission = new Permission();
$permission->name = $request->input('name');
$permission->display_name = $request->input('displayname');
$permission->description = $request->input('description');
$permission->save();
$results->info = 'permission edit';
}
$results->status = 1;
$results->result = $permission;
} else {
$results->status = 0;
$result = array();
foreach ($validator->errors() as $key => $err) {
array_push($result, $err);
}
$results->result = $result;
}
return response()->json($results);
}
示例2: putAddpermission
public function putAddpermission($id)
{
$rol = Role::find($id);
$per = Permission::find(Request::input('permission_id'));
$rol->attachPermission($per);
return $per;
}
示例3: postLearn
public function postLearn(Request $request)
{
$permission = Permission::find($request->input('permission_id'));
$permission->learning_user_id = $request->input('user_id');
$permission->save();
return redirect('/');
}
示例4: revokePermission
public function revokePermission($id, $permission_id)
{
$role = Role::find($id);
$permission = Permission::find($permission_id);
$role->revokePermission($permission);
return redirect()->back();
}
示例5: show
/**
* Display the specified resource.
*
* @param int $id
*
* @return Response
*/
public function show($id)
{
$permission = Permission::find($id);
if (is_null($permission)) {
throw new NotFoundException();
}
return response()->item($permission, new PermissionTransformer());
}
示例6: delete
/**
* Delete permission
*
* @param int $id
* @throws SaveException
*/
public static function delete($id)
{
try {
$permission = PermissionModel::find($id);
$permission->delete();
} catch (Exception $e) {
throw $e;
}
}
示例7: destroy
public function destroy($id)
{
$permissions = Permission::find($id);
if ($permissions->id != 1) {
$permissions->delete();
return redirect()->action('Admin\\PermissionsController@index');
} else {
return redirect()->action('Admin\\PermissionsController@index')->with('error', 'Something went wrong.');
}
}
示例8: find
/**
* @param $id
* @param bool $withRoles
* @throws GeneralException
* @return \Illuminate\Database\Eloquent\Model|\Illuminate\Support\Collection|null|static
*/
public function find($id, $withRoles = false)
{
if (!is_null(Permission::find($id))) {
if ($withRoles) {
return Permission::with('roles')->find($id);
}
return Permission::find($id);
}
throw new GeneralException('That permission does not exist.');
}
示例9: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Permission::find();
$dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => false]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'category', $this->category]);
$query->orderBy('category');
return $dataProvider;
}
示例10: testStore
public function testStore()
{
echo "\n\nPERMISSION CONTROLLER TEST\n\n";
$this->withoutMiddleware();
$this->call('POST', '/permission', $this->permissionRolesMapping);
$permission1 = Permission::find(1);
$permission2 = Permission::find(2);
$permission3 = Permission::find(3);
$role1 = Role::find(1);
$role2 = Role::find(2);
$this->assertTrue($permission1->hasRole($role1->name));
$this->assertTrue($permission2->hasRole($role2->name));
$this->assertTrue($permission3->hasRole($role2->name));
$this->assertFalse($permission3->hasRole($role1->name));
$this->assertFalse($permission1->hasRole($role2->name));
// todo: sort this failing
// $this->assertRedirectedToRoute('permission.index');
}
示例11: destroy
public function destroy($id)
{
Permission::find($id)->delete();
return redirect()->route('admin.permissions.index');
}
示例12: update
public function update($id, UpdatePermissionRequest $request)
{
$permission = Permission::find($id);
$permission->update($request->all());
return redirect()->route('permissions.show', $id)->with('successes', ['Permission updated successfully']);
}
示例13: getPermissionById
public function getPermissionById($id)
{
return Permission::find($id);
}
示例14: permissions
public function permissions(Request $request)
{
try {
$permission = Permission::find($request->get('permission_id'));
$role = Role::find($request->get('role_id'));
$role->givePermissionTo($permission);
Flash::success('The permission "' . $permission->permission_name . '" was successfully assigned to the role "' . $role->role_name . '"');
} catch (\Exception $e) {
Flash::danger('The relationship you specified already exists: ' . $e->getMessage());
}
return back();
}
示例15: destroy
/**
* Remove the specified Permission from storage.
*
* @param int $id
*
* @return Response
*/
public function destroy($id)
{
/** @var Permission $permissions */
$permission = Permission::find($id);
if (empty($permission)) {
Flash::error('Permissions not found');
return redirect(route('admin.permissions.index'));
}
$permission->delete();
Flash::message('Permission deleted successfully.');
return redirect(route('admin.permissions.index'));
}