Beispiel #1
0
 public function store(CreateQuranEvaluatorRequest $request, User $user)
 {
     // return($request->all());
     $user->fill($request->except("password"));
     $user->password = bcrypt($request->input('password'));
     $user->save();
     if ($request->input('user_type') == 1) {
         $role = Role::where('name', 'القرآن الكريم 1')->first();
     } else {
         $role = Role::where('name', 'القرآن الكريم 2')->first();
     }
     if ($role) {
         $user->attachRole($role->id);
     }
     $message = 'تم اضافة حساب ' . $user->name . ' بنجاح';
     $user->quran_subjects()->sync($request->input('subjects', []));
     $user->quran_students()->sync($request->input('students', []));
     if (request('submit') == 'save') {
         return redirect()->back()->with('success', $message);
     } else {
         return redirect()->route('evaluators.quran.index')->with('success', $message);
     }
 }
Beispiel #2
0
 /**
  * update a user with the data from the edit form
  * @param  UpdateUserRequest $req  [description]
  * @param  User              $user [description]
  * @return \Illuminate\Support\Facades\Redirect                  [description]
  */
 public function update(UpdateUserRequest $req, User $user)
 {
     $user->fill($req->except('password'));
     if ($user->type != 'admin') {
         return redirect()->route('welcome');
     }
     if (!empty($req->input('password'))) {
         $user->password = bcrypt($req->input('password'));
     }
     $user->save();
     // sync roles with user
     $user->detachAllRoles();
     if ($req->has('role')) {
         foreach ($req->input('role') as $role) {
             $user->attachRole($role);
         }
     }
     $this->processPermissions($user);
     $message = trans('users::users.update_success', ['name' => $user->name]);
     if (request('submit') == 'save') {
         return redirect()->back()->with('success', $message);
     }
     return redirect()->route('users.index')->with('success', $message);
 }
Beispiel #3
0
 /**
  * update a user with the data from the edit form
  * @param  UpdateUserRequest $req  [description]
  * @param  User              $user [description]
  * @return \Illuminate\Support\Facades\Redirect                  [description]
  */
 public function update(UpdateUserRequest $req, User $user)
 {
     $user->fill($req->all());
     if ($user->type != 'admin') {
         return redirect()->route('welcome');
     }
     if (!empty($req->input('password'))) {
         $user->password = bcrypt($req->input('password'));
     }
     $user->save();
     $this->processPermissions($user);
     $message = trans('users::users.update_success', ['name' => $user->name]);
     if (request('submit') == 'save') {
         return redirect()->back()->with('success', $message);
     }
     return redirect()->route('users.index')->with('success', $message);
 }