App\Ninja\Intents\InvoiceIntent::stateInvoice PHP Méthode

stateInvoice() protected méthode

protected stateInvoice ( )
    protected function stateInvoice()
    {
        $invoiceId = $this->stateEntity(ENTITY_INVOICE);
        if (!$invoiceId) {
            throw new Exception(trans('texts.intent_not_supported'));
        }
        $invoice = Invoice::scope($invoiceId)->first();
        if (!$invoice) {
            throw new Exception(trans('texts.intent_not_supported'));
        }
        if (!Auth::user()->can('view', $invoice)) {
            throw new Exception(trans('texts.not_allowed'));
        }
        return $invoice;
    }