Exemplo n.º 1
0
 public function all($params)
 {
     $params['order'] = isset($params['order']) ? $params['order'] : ['display_name|ASC'];
     $roles = Role::select("roles.*");
     $roles = parent::execute($roles, $params);
     return $roles;
 }
Exemplo n.º 2
0
 public function create()
 {
     $roles = Role::select('id', 'role_name')->get();
     $roles = $this->toOptionArray($roles);
     //dd($roles);
     return view($this->view_path . 'create', compact('roles', 'data'));
 }
Exemplo n.º 3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $role = Role::select('id')->where('name', '=', 'admin')->first();
     $user = User::create(['name' => 'Administrador', 'lastname' => 'Administrador', 'email' => '*****@*****.**', 'password' => bcrypt('admin'), 'dni' => '34785999', 'state_id' => '12', 'city_id' => '228', 'role_id' => $role->id, 'active' => '1']);
     $role = Role::select('id')->where('name', '=', 'user')->first();
     $user = User::create(['name' => 'User', 'lastname' => 'User', 'email' => '*****@*****.**', 'password' => bcrypt('123456'), 'dni' => '34785998', 'state_id' => '12', 'city_id' => '228', 'role_id' => $role->id, 'active' => '1']);
 }
Exemplo n.º 4
0
 public static function update(UserRequest $request, $id)
 {
     $user = User::find($id);
     if (!$user) {
         return redirect()->back()->withErrors('No se encontro el usuario solicitado');
     }
     $role = Role::select('name', 'id')->where('id', '=', $request->input('role_id'))->first();
     if ($role->name == 'Admin') {
         //Admin
         $user->role_id = $role->id;
     } else {
         //Client
         $client = Role::select('id')->where('name', '=', 'User')->first();
         //$token = str_random(32);
         $user->role_id = $client->id;
         //$user->active = 0;
     }
     if (!$request->has('active')) {
         //check checkbox :D
         $user->active = 0;
     } else {
         $user->active = $request->input('active');
     }
     $user->password = Hash::make($request->input('password'));
     $user->name = $request->input('name');
     $user->lastname = $request->input('lastname');
     $user->email = $request->input('email');
     $user->dni = $request->input('dni');
     $user->state_id = $request->input('state_id');
     $user->city_id = $request->input('city_id');
     $user->save();
     return redirect()->route('users.index')->with('success', 'El usuario se ha modificado correctamente');
 }
Exemplo n.º 5
0
 /**
  * Function Remove
  * Process Delete the Brand Data
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function onDelete()
 {
     $id = Input::get('id');
     $Model = \App\Models\Role::select(['id'])->where('id', $id)->first();
     if ($Model) {
         \App\Models\Role::where('id', $id)->delete();
         $param['message'] = Lang::get('info.has deleted');
         $param['error'] = false;
     } else {
         $param['message'] = Lang::get('info.has error');
         $param['error'] = true;
     }
     return json_encode($param);
 }