orderId = $orderId; $this->step = new StepObject(self::STEP_REFERENCE, $completeDate); } /** * @return bool */ public function validator(): bool { return true; } /** * @return JsonResponse * @throws InternalServerErrorException */ public function execute(): JsonResponse { Mail::send('emails.received_orders_email', [], function ($message) { $message->from('noreply@izyin.com', 'IZYIM'); $message->to('uldvstar@gmail.com', 'Omair Saleh')->subject('Received orders report '.now()->format('dd/mm/YY')); $message->attach( Excel::download(Order::find($this->orderId), 'report_'.now()->format('dd_mm_YY').'.xlsx') ->getFile(), ['as' => 'report_'.now()->format('dd/mm/YY').'.xlsx']); }); return $this->handler($this->orderId, $this->step); } }