當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Role::findOrFail方法代碼示例

本文整理匯總了PHP中Role::findOrFail方法的典型用法代碼示例。如果您正苦於以下問題:PHP Role::findOrFail方法的具體用法?PHP Role::findOrFail怎麽用?PHP Role::findOrFail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Role的用法示例。


在下文中一共展示了Role::findOrFail方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: update

 /**
  * Update the specified resource in storage.
  * PUT /roles/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $role = \Role::findOrFail($id);
     $role->update(\Input::all());
     $role->assignPermissions(\Input::get('permissions'));
     return \Redirect::route('admin.roles.index');
 }
開發者ID:pogliozzy,項目名稱:larabase,代碼行數:14,代碼來源:RolesController.php

示例2: update

 /**
  * Update the specified role in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $role = Role::findOrFail($id);
     $validator = Validator::make($data = Input::all(), Role::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $role->update($data);
     return Redirect::route('roles.index');
 }
開發者ID:arbuuuud,項目名稱:gnt-aops,代碼行數:16,代碼來源:RolesController.php

示例3: update

 /**
  * Update the specified resource in storage.
  * PUT /roles/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $role = Role::findOrFail($id);
     if ($role) {
         $perms = Input::get('perms');
         $permsToAttach = [];
         if (Input::has('perms')) {
             foreach ($perms as $key => $value) {
                 $perm = Permission::where('id', '=', $key)->first();
                 if ($perm) {
                     array_push($permsToAttach, $perm->id);
                 }
             }
         }
         $role->perms()->sync($permsToAttach);
         if (Input::has('display_name')) {
             $role->display_name = Input::get('display_name');
         }
         $role->save();
         return Redirect::to('admin/roles')->with(['roles-notice' => 'Role has been updated']);
     }
     return Redirect::to('admin/roles')->with(['roles-notice' => 'Error updating role']);
 }
開發者ID:vanderlin,項目名稱:halp,代碼行數:30,代碼來源:RolesController.php

示例4: moderator

 public static function moderator()
 {
     return Role::findOrFail(32);
 }
開發者ID:bishopb,項目名稱:laravel-forums,代碼行數:4,代碼來源:RoleRepository.php

示例5: show

 /**
  * Display the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function show($id)
 {
     $role = $this->role->findOrFail($id);
     return View::make('roles.show', compact('role'));
 }
開發者ID:alex-petkevich,項目名稱:proweb5,代碼行數:11,代碼來源:RolesController.php

示例6: destroy

 /**
  * Remove the specified role from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $role = Role::findOrFail($id);
     if (!$role->canDelete()) {
         return $this->_access_denied();
     }
     if (!$role->delete()) {
         return $this->_delete_error();
     }
     if (Request::ajax()) {
         return Response::json($this->deleted_message);
     }
     return Redirect::route('roles.index')->with('notification:success', $this->deleted_message);
 }
開發者ID:k4ml,項目名稱:laravel-base,代碼行數:20,代碼來源:RolesController.php

示例7: edit

 public function edit()
 {
     $role = Role::findOrFail(Input::get('role_id'));
     $permissions = $role->perms()->get();
     return View::make('roles.edit', compact('role', 'permissions'));
 }
開發者ID:nelug,項目名稱:ControlDePlanilla,代碼行數:6,代碼來源:RolesController.php

示例8: show

 /**
  * Display the specified role.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $role = Role::findOrFail($id);
     $this->layout->title = 'Add Role';
     $this->layout->content = View::make('roles.show', compact('role'));
 }
開發者ID:vik0803,項目名稱:BugTrackerApp,代碼行數:12,代碼來源:RolesController.php


注:本文中的Role::findOrFail方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。