app/Http/Controllers/InvoiceController.php
/**
     * @param InvoiceRequest $request
     * @param PersonRequest $personRequest
     * @return RedirectResponse
     * @throws \Exception
     */
@param InvoiceRequest $request
@param PersonRequest $personRequest
@return RedirectResponse
@throws \Exception
@param InvoiceRequest $request @param PersonRequest $personRequest @return RedirectResponse @throws \ Exception
public function store(InvoiceRequest $request, PersonRequest $personRequest): RedirectResponse
    {
        $newInvoice = $request->input();
        $recipient = $this->persons->store($personRequest);
        if ($recipient === null) {
            return back()
                ->withInput();
        }
        $invoice = Invoice::query()->make($newInvoice);
        $invoice->recipient_id = $recipient->id;
        $invoice->sender_id = auth()->user()->id;
        $invoice->code = strtoupper(substr(sha1(random_bytes(20)), 0, 20));
        $invoice->save();
        if ($invoice) {
            return redirect()
                ->route('invoices.index');
        }
        return back()
            ->withInput();
    }
public function store ( InvoiceRequest $ request , PersonRequest $ personRequest ) : RedirectResponse { $ newInvoice = $ request -> input ( ) ; $ recipient = $ this -> persons -> store ( $ personRequest ) ; if ( $ recipient === null ) { return back ( ) -> withInput ( ) ; } $ invoice = Invoice :: query ( ) -> make ( $ newInvoice ) ; $ invoice -> recipient_id = $ recipient -> id ; $ invoice -> sender_id = auth ( ) -> user ( ) -> id ; $ invoice -> code = strtoupper ( substr ( sha1 ( random_bytes ( 20 ) ) , 0 , 20 ) ) ; $ invoice -> save ( ) ; if ( $ invoice ) { return redirect ( ) -> route ( 'invoices.index' ) ; } return back ( ) -> withInput ( ) ; }
@param InvoiceRequest $request
 @param PersonRequest $personRequest
 @return RedirectResponse
 @throws \Exception
@param InvoiceRequest $request @param PersonRequest $personRequest @return RedirectResponse @throws \ Exception
/** @var Recipient $recipient */ /** @var Invoice $invoice */