app/Http/Controllers/InvoicesController.php
/**
     * Remove the specified resource from storage.
     *
     * @param  \App\invoices  $invoices
     * @return \Illuminate\Http\Response
     */
Remove the specified resource from storage.
Remove the specified resource from storage .
public function destroy(Request $request)
    {
        $id = $request->invoice_id;
        $invoice = invoices::where('id',$id)->first();
        $attachs = invoices_attachments::where('invoices_id',$id)->first();
        if (!$request->id_page == 2) {
            if (!empty($attachs->invoices_number)) {
                Storage::disk('public_uploads')->deleteDirectory($attachs->invoices_number);
        }
        $invoice->forceDelete();
        session()->flash('delete_invoice');
        return redirect('/invoices');
        }else{
            $invoice->delete();
            session()->flash('Archive_invoice');
            return redirect('/Archive');
        }
    }
public function destroy ( Request $ request ) { $ id = $ request -> invoice_id ; $ invoice = invoices :: where ( 'id' , $ id ) -> first ( ) ; $ attachs = invoices_attachments :: where ( 'invoices_id' , $ id ) -> first ( ) ; if ( ! $ request -> id_page == 2 ) { if ( ! empty ( $ attachs -> invoices_number ) ) { Storage :: disk ( 'public_uploads' ) -> deleteDirectory ( $ attachs -> invoices_number ) ; } $ invoice -> forceDelete ( ) ; session ( ) -> flash ( 'delete_invoice' ) ; return redirect ( '/invoices' ) ; } else { $ invoice -> delete ( ) ; session ( ) -> flash ( 'Archive_invoice' ) ; return redirect ( '/Archive' ) ; } }
Remove the specified resource from storage.
Remove the specified resource from storage .