cancel invoice/bill
This commit is contained in:
		
							
								
								
									
										38
									
								
								app/Jobs/Sale/CancelInvoice.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								app/Jobs/Sale/CancelInvoice.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,38 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Jobs\Sale;
 | 
			
		||||
 | 
			
		||||
use App\Abstracts\Job;
 | 
			
		||||
use App\Models\Sale\Invoice;
 | 
			
		||||
 | 
			
		||||
class CancelInvoice extends Job
 | 
			
		||||
{
 | 
			
		||||
    protected $invoice;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Create a new job instance.
 | 
			
		||||
     *
 | 
			
		||||
     * @param  $invoice
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct($invoice)
 | 
			
		||||
    {
 | 
			
		||||
        $this->invoice = $invoice;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Execute the job.
 | 
			
		||||
     *
 | 
			
		||||
     * @return Invoice
 | 
			
		||||
     */
 | 
			
		||||
    public function handle()
 | 
			
		||||
    {
 | 
			
		||||
        $this->deleteRelationships($this->invoice, [
 | 
			
		||||
            'transactions', 'recurring'
 | 
			
		||||
        ]);
 | 
			
		||||
 | 
			
		||||
        $this->invoice->status = 'cancelled';
 | 
			
		||||
        $this->invoice->save();
 | 
			
		||||
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user