Updated / Refactoring of PDF ticket mailers/jobs

This commit is contained in:
Dave Earley 2016-06-15 13:34:12 +01:00
parent 39fb757926
commit 6bd4947fd8
6 changed files with 44 additions and 5 deletions

View File

@ -19,6 +19,7 @@ use DB;
use Excel;
use Mail;
use Omnipay\Omnipay;
use PDF;
use Response;
use Validator;
use Config;
@ -820,4 +821,33 @@ class EventAttendeesController extends MyBaseController
'message' => 'Ticket Successfully Resent',
]);
}
/**
* Show an attendee ticket
*
* @param Request $request
* @param $attendee_id
* @return bool
*/
public function showAttendeeTicket(Request $request, $attendee_id)
{
$attendee = Attendee::scope()->findOrFail($attendee_id);
$data = [
'order' => $attendee->order,
'event' => $attendee->event,
'tickets' => $attendee->ticket,
'attendees' => [$attendee],
'css' => file_get_contents(public_path('assets/stylesheet/ticket.css')),
'image' => base64_encode(file_get_contents(public_path($attendee->event->organiser->full_logo_path))),
];
if ($request->get('download') == '1') {
return PDF::html('Public.ViewEvent.Partials.PDFTicket', $data, 'Tickets');
}
return view('Public.ViewEvent.Partials.PDFTicket', $data);
}
}

View File

@ -443,6 +443,11 @@ Route::group(['middleware' => ['auth', 'first.run']], function () {
'uses' => 'EventAttendeesController@showExportTicket',
]);
Route::get('{event_id}/attendees/{attendee_id}/ticket', [
'as' => 'showAttendeeTicket',
'uses' => 'EventAttendeesController@showAttendeeTicket',
]);
Route::get('{event_id}/attendees/export/{export_as?}', [
'as' => 'showExportAttendees',
'uses' => 'EventAttendeesController@showExportAttendees',

View File

@ -4,15 +4,15 @@ namespace App\Jobs;
use App\Jobs\Job;
use App\Mailers\AttendeeMailer;
use App\Mailers\TicketMailer;
use App\Models\Attendee;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
class SendAttendeeTicket extends Job implements ShouldQueue
{
use InteractsWithQueue, SerializesModels;
use InteractsWithQueue, SerializesModels, DispatchesJobs;
public $attendee;
@ -33,6 +33,7 @@ class SendAttendeeTicket extends Job implements ShouldQueue
*/
public function handle(AttendeeMailer $attendeeMailer)
{
$this->dispatchNow(new GenerateTicket($this->attendee->reference));
$attendeeMailer->sendAttendeeTicket($this->attendee);
}
}

View File

@ -5,13 +5,14 @@ namespace App\Jobs;
use App\Jobs\Job;
use App\Mailers\OrderMailer;
use App\Models\Order;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
class SendOrderTickets extends Job implements ShouldQueue
{
use InteractsWithQueue, SerializesModels;
use InteractsWithQueue, SerializesModels, DispatchesJobs;
public $order;
@ -32,6 +33,7 @@ class SendOrderTickets extends Job implements ShouldQueue
*/
public function handle(OrderMailer $orderMailer)
{
$this->dispatchNow(new GenerateTicket($this->order->order_reference));
$orderMailer->sendOrderTickets($this->order);
}
}

View File

@ -37,7 +37,7 @@ class OrderCompletedListener implements ShouldQueue
/**
* Generate the PDF tickets and send notification emails etc.
*/
Log::info('Processing Order: ' . $event->order->order_reference);
Log::info('Begin Processing Order: ' . $event->order->order_reference);
$this->dispatchNow(new GenerateTicket($event->order->order_reference));
$this->dispatch(new SendOrderTickets($event->order));
$this->dispatch(new SendOrderNotification($event->order));

View File

@ -9,6 +9,7 @@ use Carbon\Carbon;
use Mail;
use Log;
class AttendeeMailer extends Mailer
{
@ -25,7 +26,7 @@ class AttendeeMailer extends Mailer
$message->to($attendee->email);
$message->subject('Your ticket for the event ' . $attendee->order->event->title);
$file_name = $attendee->getReferenceAttribute();
$file_name = $attendee->reference;
$file_path = public_path(config('attendize.event_pdf_tickets_path')) . '/' . $file_name . '.pdf';
$message->attach($file_path);