Exemple #1
0
 /**
  * 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;
 }
Exemple #2
0
 /**
  * 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();
 }