app/Http/Controllers/TenancyController.php
/**
     * @param TenancyRequest $request
     * @return array
     * @throws ValidationException
     */
@param TenancyRequest $request
@return array
@throws ValidationException
@param TenancyRequest $request @return array @throws ValidationException
public function store(TenancyRequest $request)
    {
        $request->fallsIntoExistingTimePeriods($request);
        $tenancyData = $request->only([
                'property_id',
                'tenant_id',
                'start_date',
                'end_date',
                'monthly_rent',
            ]) + [
                'user_id' => $request->user()->id,
                'invoice' => 'invoice_' . time() . '.pdf',
            ];
        Tenancy::create($tenancyData);
        Storage::put("invoices/invoice_" . time() . ".pdf",
            PdfDataLoader::loadPdf($request)->output());
        return ["message" => 'Tenancy Created'];
    }
public function store ( TenancyRequest $ request ) { $ request -> fallsIntoExistingTimePeriods ( $ request ) ; $ tenancyData = $ request -> only ( [ 'property_id' , 'tenant_id' , 'start_date' , 'end_date' , 'monthly_rent' , ] ) + [ 'user_id' => $ request -> user ( ) -> id , 'invoice' => 'invoice_' . time ( ) . '.pdf' , ] ; Tenancy :: create ( $ tenancyData ) ; Storage :: put ( " invoices/invoice_ " . time ( ) . " .pdf " , PdfDataLoader :: loadPdf ( $ request ) -> output ( ) ) ; return [ " message " => 'Tenancy Created' ] ; }
@param TenancyRequest $request
 @return array
 @throws ValidationException
@param TenancyRequest $request @return array @throws ValidationException