<?php

namespace App\Jobs;

use App\Models\Payement;
use App\Models\Transaction;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\DB;

class PayementBoarding implements ShouldQueue
{
    use Dispatchable, Queueable, SerializesModels;
    private $boardingPass;
    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($boardingPass)
    {
      $this->boardingPass = $boardingPass;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
       $account = auth()->user()->office->account;
      
       $amount = $this->boardingPass->amount;

       Payement::create([
            'boarding_pass_id' => $this->boardingPass->id,
            'currency_code' => $account->currency_code,
            'amount' =>  $amount
       ]);
    }
}
