2016-02-29 15:59:36 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Commands;
|
|
|
|
|
|
|
|
|
|
use App\Attendize\mailers\OrderMailer;
|
|
|
|
|
use Illuminate\Contracts\Bus\SelfHandling;
|
2016-03-11 15:51:39 +00:00
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
2016-03-05 00:18:10 +00:00
|
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
|
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
|
use Log;
|
2016-02-29 15:59:36 +00:00
|
|
|
|
2016-03-11 15:51:39 +00:00
|
|
|
class OrderTicketsCommand extends Command implements ShouldQueue, SelfHandling
|
2016-03-05 00:18:10 +00:00
|
|
|
{
|
2016-02-29 15:59:36 +00:00
|
|
|
use InteractsWithQueue,
|
|
|
|
|
SerializesModels;
|
|
|
|
|
|
|
|
|
|
public $ticketOrder, $sendOrderConfirmation;
|
|
|
|
|
private $outSeperator = "\n ---------------------- \n";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* OrderTicketsCommand constructor.
|
2016-03-05 00:18:10 +00:00
|
|
|
*
|
2016-02-29 15:59:36 +00:00
|
|
|
* @param \App\Models\Order $ticketOrder
|
2016-03-05 00:18:10 +00:00
|
|
|
* @param bool|true $sendOrderConfirmation
|
2016-02-29 15:59:36 +00:00
|
|
|
*/
|
2016-03-05 00:18:10 +00:00
|
|
|
public function __construct(\App\Models\Order $ticketOrder, $sendOrderConfirmation = true)
|
|
|
|
|
{
|
2016-02-29 15:59:36 +00:00
|
|
|
$this->ticketOrder = $ticketOrder;
|
|
|
|
|
$this->sendOrderConfirmation = $sendOrderConfirmation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param OrderMailer $mailer
|
|
|
|
|
*/
|
2016-03-05 00:18:10 +00:00
|
|
|
public function handle(OrderMailer $mailer)
|
|
|
|
|
{
|
|
|
|
|
Log::info(date('d m y H:i')." - Starting Job {$this->job->getJobId()} ".__CLASS__);
|
2016-02-29 15:59:36 +00:00
|
|
|
|
|
|
|
|
//1 - Notify event organiser
|
2016-03-05 00:18:10 +00:00
|
|
|
if ($this->sendOrderConfirmation) {
|
|
|
|
|
$mailer->sendOrderNotification($this->ticketOrder);
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
2016-03-05 00:18:10 +00:00
|
|
|
|
2016-02-29 15:59:36 +00:00
|
|
|
//2 - Generate PDF Tickets
|
|
|
|
|
$this->ticketOrder->generatePdfTickets();
|
2016-03-05 00:18:10 +00:00
|
|
|
|
2016-02-29 15:59:36 +00:00
|
|
|
//3 - Send Tickets / Order confirmation
|
|
|
|
|
$mailer->sendOrderConfirmation($this->ticketOrder);
|
|
|
|
|
|
2016-03-05 00:18:10 +00:00
|
|
|
Log::info(date('d m y H:i')." - Finished Job {$this->job->getJobId()} ".__CLASS__);
|
2016-02-29 15:59:36 +00:00
|
|
|
|
|
|
|
|
$this->delete();
|
|
|
|
|
}
|
|
|
|
|
}
|