invoice = $invoice; } /** * Execute the job. * * @return boolean|Exception */ public function handle() { $this->authorize(); \DB::transaction(function () { Transaction::mute(); $this->deleteRelationships($this->invoice, [ 'items', 'item_taxes', 'histories', 'transactions', 'recurring', 'totals' ]); $this->invoice->delete(); Transaction::unmute(); }); return true; } /** * Determine if this action is applicable. * * @return void */ public function authorize() { if ($this->invoice->transactions()->isReconciled()->count()) { $message = trans('messages.warning.reconciled_doc', ['type' => trans_choice('general.invoices', 1)]); throw new \Exception($message); } } }