2023-01-14 21:37:23 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Listeners;
|
|
|
|
|
|
|
|
use App\Events\PaymentEvent;
|
|
|
|
use App\Traits\Invoiceable;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
|
|
|
2023-01-14 23:41:31 +00:00
|
|
|
class CreateInvoice implements ShouldQueue
|
2023-01-14 21:37:23 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
use Invoiceable;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle the event.
|
|
|
|
*
|
|
|
|
* @param \App\Events\PaymentEvent $event
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function handle(PaymentEvent $event)
|
|
|
|
{
|
|
|
|
if (config('SETTINGS::INVOICE:ENABLED') == 'true') {
|
|
|
|
// get user from payment which does hold the user_id
|
|
|
|
$user = $event->payment->user;
|
2023-01-14 23:41:31 +00:00
|
|
|
|
2023-01-14 21:37:23 +00:00
|
|
|
// create invoice using the trait
|
|
|
|
$this->createInvoice($user, $event->payment);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|