Exemplo n.º 1
0
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     $roles = Role::lists('name', 'id');
     $locales = Locale::where('status', '<>', 'disabled')->lists('name', 'id');
     $companies = Company::lists('name', 'id');
     $usertypes = Usertype::lists('name', 'id');
     //dc($usertypes);
     return view('user::create', compact('roles', 'locales', 'companies', 'usertypes'));
 }
Exemplo n.º 2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     //Auth::logout();
     $action = DB::transaction(function () use($id) {
         try {
             $role = Role::findOrFail($id);
             Role::destroy($id);
             if (request()->ajax()) {
                 $data = ['status' => 'succes', 'statusText' => 'Ok', 'responseText' => 'Rol \'' . $role->name . '\' is verwijderd'];
                 return response()->json($data, 200);
             }
             Flash::success('De rol ' . $id . '');
         } catch (\Exception $e) {
             if (request()->ajax()) {
                 $data = ['status' => 'succes', 'statusText' => 'Fail', 'responseText' => '' . $e->getMessage() . ''];
                 return response()->json($data, 400);
             }
             Flash::error('Delete is mislukt!<br>' . $e->getMessage() . ' ' . $id . '');
         }
     });
     if (request()->ajax()) {
         return $action;
     }
     return redirect()->back();
 }