Example #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);
     }
 }