Exemplo n.º 1
0
 /**
  * Email sticker pdf to driver
  *
  * @param $job
  * @param $data
  */
 public function email($job, $data)
 {
     $view_data = !empty($data['data']) ? $data['data'] : [];
     // Process the send sticker pdf to user email event...
     try {
         \Mail::queue($data['template'], $view_data, function ($message) use($data) {
             $message->from($data['context']['from'], $data['context']['name'])->subject($data['context']['subject']);
             $message->to($data['to']);
             if (isset($data['attach'])) {
                 $message->attach($data['attach'], array('as' => $data['as'], 'mime' => $data['mime']));
             }
         });
         if ($driver = Driver::findByEmail($data['to'])) {
             $driver->type = "emails";
             \Event::fire('paxifi.notifications.emails', [$driver]);
         }
         $job->delete();
     } catch (\Exception $e) {
         return \Response::json(["error" => true, "message" => ""], 500, []);
     }
 }