Esempio n. 1
0
 /**
  * @param UserModel $model
  * @param UsersRequest $request
  * @return array|\Illuminate\Http\RedirectResponse
  */
 private function save(UserModel $model, UsersRequest $request)
 {
     return \DB::transaction(function () use($model, $request) {
         $data = $request->input('user', []);
         $model->fill($data);
         $password = $request->input('password');
         if ($password !== null && strlen($password = trim($password)) > 0) {
             $model->setPasswordAttribute($password);
         }
         $result = $model->save();
         $model->groups()->sync($request->input('groups', []));
         if ($request->ajax()) {
             return ['result' => $result];
         }
         return \Redirect::route('backend.backend.users');
     });
 }