public function registerDoctor(RegisterDoctorRequest $request) { $doctor = new User(); $doctor->name = $request->name; $doctor->email = $request->email; $doctor->password = $request->password; $doctor->specialization_id = $request->specialization_id; $doctor->license_number = $request->license_number; $doctor->confirmed = 1; $doctor->save(); //Attach new roles $doctor->attachRoles([3]); //Attach other permissions $doctor->attachPermissions([24]); return redirect()->back()->withFlashSuccess('Entry Saved!'); }
/** * @param User $user * @param $status * @throws GeneralException * @return bool */ public function mark(User $user, $status) { if (access()->id() == $user->id && $status == 0) { throw new GeneralException(trans('exceptions.backend.access.users.cant_deactivate_self')); } $user->status = $status; //Log history dependent on status switch ($status) { case 0: event(new UserDeactivated($user)); break; case 1: event(new UserReactivated($user)); break; } if ($user->save()) { return true; } throw new GeneralException(trans('exceptions.backend.access.users.mark_error')); }
/** * @param array $data * @param bool $provider * @return static */ public function create(array $data, $provider = false) { $user = new User(); $user->name = $data['name']; $user->email = $data['email']; $user->confirmation_code = md5(uniqid(mt_rand(), true)); $user->status = 1; $user->password = $provider ? null : bcrypt($data['password']); $user->confirmed = $provider ? 1 : (config('access.users.confirm_email') ? 0 : 1); DB::transaction(function () use($user) { if ($user->save()) { /** * Add the default site role to the new user */ $user->attachRole($this->role->getDefaultUserRole()); } }); /** * If users have to confirm their email and this is not a social account, * send the confirmation email * * If this is a social account they are confirmed through the social provider by default */ if (config('access.users.confirm_email') && $provider === false) { $this->sendConfirmationEmail($user); } /** * Return the user object */ return $user; }