Esempio n. 1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $rules = ['password' => 'confirmed|min:6'];
     if (Auth::user()->admin) {
         $rules['username'] = '******';
         $rules['institution_id'] = 'integer';
     }
     $this->validate($request, $rules);
     if (Auth::user()->admin) {
         $data = Input::only(['username', 'institution_id', 'admin']);
         $data['admin'] = Input::has('admin') ? true : false;
         if (empty($data['institution_id'])) {
             $data['institution_id'] = null;
         }
     }
     $data['password'] = Input::get('password');
     if (!empty($data['password'])) {
         $data['password'] = bcrypt($data['password']);
     } else {
         unset($data['password']);
     }
     User::find($id)->update($data);
     return Redirect::route(Auth::user()->admin ? 'users.index' : 'home');
 }
Esempio n. 2
0
 public function run()
 {
     DB::table('users')->delete();
     User::create(array('name' => 'Administrator', 'username' => 'Admin', 'password' => bcrypt('TAEadmin'), 'admin' => true));
 }
Esempio n. 3
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     return User::create(['username' => $data['username'], 'institution_id' => $data['institution_id'], 'password' => bcrypt($data['password'])]);
 }