コード例 #1
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $data['role'] = Role::find($id);
     $data['modules'] = Module::all();
     //dd($data['role']->roleDetails->where('id_module',137)->first()->module->name);
     return view('admin.role_details.index', compact('data'));
 }
コード例 #2
0
ファイル: RoleController.php プロジェクト: patopoc/hotpms
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id, Request $request)
 {
     $role = Role::findOrFail($id);
     $message = "";
     try {
         $role->delete();
         $message = trans('appstrings.item_removed', ['item' => $role->name]);
         Session::flash('message_type', 'success');
     } catch (\PDOException $e) {
         $message = trans('sqlmessages.' . $e->getCode());
         if ($message == 'sqlmessages.' . $e->getCode()) {
             $message = trans('sqlmessages.undefined');
         }
         if ($request->ajax()) {
             return ['code' => 'error', 'message' => $message];
         }
         Session::flash('message_type', 'error');
     }
     if ($request->ajax()) {
         return ['code' => 'ok', 'message' => $message];
     }
     Session::flash('message', $message);
     return redirect()->route('admin.roles.index');
 }