Example #1
0
 /**
  * Обновление пользоватея в БД
  * @param AdminUserRequest $request
  * @param $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postUpdate(AdminUserRequest $request, $id)
 {
     $user = $this->model->find($id);
     $user->nickname = $request->input('nickname');
     $user->access = $request->input('access');
     //Устанавливаем статус
     if ($request->has('status')) {
         $user->status = $request->input('status');
     } else {
         $user->status = 0;
     }
     //Сохраняем в бд
     $user->save();
     //Обновление профиля
     $profile = Profile::where('user_id', $user->id)->first();
     $profile->first_name = $request->input('first_name');
     $profile->last_name = $request->input('last_name');
     $profile->avatar = $request->input('avatar');
     $profile->save();
     return redirect()->route('admin.user.index')->with('success', 'Информация о пользователе обновлена!');
 }
Example #2
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     $user = User::create(['nickname' => clean($data['nickname'], ['HTML.Allowed' => '']), 'email' => $data['email'], 'password' => bcrypt($data['password']), 'access' => 'user', 'status' => 0, 'activation_code' => str_random()]);
     Profile::create(['first_name' => clean($data['first_name'], ['HTML.Allowed' => '']), 'last_name' => clean($data['last_name'], ['HTML.Allowed' => '']), 'avatar' => $data['avatar'], 'user_id' => $user->id]);
     return $user;
 }
Example #3
0
 /**
  * @param View $view
  */
 public function compose(View $view)
 {
     $profile = Profile::where('user_id', $this->user->id)->first();
     $view->with(['user_module' => $this->user, 'profile' => $profile]);
 }
Example #4
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //Admin
     $user = User::create(['nickname' => 'admin', 'email' => '*****@*****.**', 'password' => bcrypt('123456'), 'status' => 1, 'access' => 'admin']);
     Profile::create(['first_name' => 'Имя', 'last_name' => 'Фамилия', 'avatar' => 'https://pixabay.com/static/uploads/photo/2013/07/13/10/07/man-156584_960_720.png', 'user_id' => $user->id]);
 }