Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Jobs;
- use Illuminate\Bus\Queueable;
- use Illuminate\Queue\SerializesModels;
- use Illuminate\Queue\InteractsWithQueue;
- use Illuminate\Contracts\Queue\ShouldQueue;
- use Illuminate\Foundation\Bus\Dispatchable;
- use App\PaymentConfirmation;
- use Carbon\Carbon;
- use App\Notifications\InvoicePaid;
- use App\TrainingOrder;
- use App\UserTicket;
- class CheckPayment implements ShouldQueue
- {
- use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
- protected $payment;
- public function __construct(PaymentConfirmation $payment)
- {
- $this->payment = $payment;
- }
- /**
- * Execute the job.
- *
- * @return void
- */
- public function handle()
- {
- if ($this->payment->created_at->diffInMinutes() >= 5) {
- $this->payment->status = 2;
- $this->payment->save();
- $training_order = TrainingOrder::findOrFail($this->payment->order_id);
- $training_order->status = TrainingOrder::CANCEL;
- $training_order->save();
- UserTicket::where('training_order_id', $training_order->id)
- ->update(['status' => UserTicket::CANCEL]);
- $user = $this->payment->order->user;
- $user->trainings()
- ->where('training_id', $training_order->training_id)
- ->updateExistingPivot($training_order->training_id, ['type' => 'unconfirmed']);
- $this->payment->order->user->notify(new InvoicePaid($this->payment));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement