/** * Execute the job. * * @return bool */ public function handle() { // Set the inquiry model data. $this->inquiry->user_id = auth()->id(); $this->inquiry->uuid = uuid(); $this->inquiry->category_id = $this->category->id; $this->inquiry->title = $this->request->input('title'); $this->inquiry->description = $this->request->input('description'); if ($this->category->manager === true) { // If the category requires manager approval, we'll retrieve the manager record. $manager = User::whereHas('roles', function (Builder $query) { $query->whereName('managers'); })->findOrFail($this->request->input('manager')); $this->inquiry->manager_id = $manager->id; // We'll send the manager a notification. $notification = new Notification($manager, 'emails.inquiries.created', ['inquiry' => $this->inquiry], function (Message $message) use($manager) { $message->subject('A New Request Requires Your Approval'); $message->to($manager->email); }); } if ($this->inquiry->save()) { // If the inquiry was successfully created, we'll // send out the notification if one has been set. if (isset($notification)) { $this->dispatch($notification); } return true; } return false; }
/** * Closes the current inquiry. * * @return bool */ public function handle() { if ($this->inquiry->isOpen()) { $this->inquiry->closed = true; return $this->inquiry->save(); } return false; }
/** * Approves the current inquiry. * * @throws AlreadyApprovedException * * @return bool */ public function handle() { if (!$this->inquiry->isApproved()) { // Close the inquiry while approving. $this->dispatch(new Close($this->inquiry)); // Set the inquiry to approved. $this->inquiry->approved = true; // Reset the inquiries UUID. $this->inquiry->uuid = null; // Save the inquiry. return $this->inquiry->save(); } throw new AlreadyApprovedException('This request has already been approved.'); }
/** * Execute the job. * * @return bool */ public function handle() { $this->inquiry->title = $this->request->input('title', $this->inquiry->title); $this->inquiry->description = $this->request->input('description', $this->inquiry->description); return $this->inquiry->save(); }