app/Http/Controllers/Student/InvoicesController.php
/**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
Display a listing of the resource.
@return \Illuminate\Http\Response
Display a listing of the resource . @return \ Illuminate \ Http \ Response
public function index()
    {
        $invoices = Auth::user()->invoices()->get();
        $status = Array();
        foreach ($invoices as $invoice)
        {
            $status[$invoice->id] = "";
            $orders = $invoice->orders() -> get();
            if (count($orders) > 0)
            {
                $paid_orders = $invoice->orders()->where(function($order){
                    return $order -> where('status_id', 5);
                }) -> get();
                if ($paid_orders != NULL) $status[$invoice->id] = "Hold For Approval";
                else $status[$invoice->id] = "Paid";
            } else if($invoice->status != "Paid")
            {
                $status[$invoice->id] = ($invoice->status == 'Reminder Sent') ? 'Unpaid' : $invoice->status;
            }
        }
        $data = [
            'invoices'  => $invoices,
            'statuses'  => $status
        ];
        return view('students.invoices.index') -> with('data', $data);
    }
public function index ( ) { $ invoices = Auth :: user ( ) -> invoices ( ) -> get ( ) ; $ status = Array ( ) ; foreach ( $ invoices as $ invoice ) { $ status [ $ invoice -> id ] = " " ; $ orders = $ invoice -> orders ( ) -> get ( ) ; if ( count ( $ orders ) > 0 ) { $ paid_orders = $ invoice -> orders ( ) -> where ( function ( $ order ) { return $ order -> where ( 'status_id' , 5 ) ; } ) -> get ( ) ; if ( $ paid_orders != NULL ) $ status [ $ invoice -> id ] = " Hold For Approval " ; else $ status [ $ invoice -> id ] = " Paid " ; } else if ( $ invoice -> status != " Paid " ) { $ status [ $ invoice -> id ] = ( $ invoice -> status == 'Reminder Sent' ) ? 'Unpaid' : $ invoice -> status ; } } $ data = [ 'invoices' => $ invoices , 'statuses' => $ status ] ; return view ( 'students.invoices.index' ) -> with ( 'data' , $ data ) ; }
Display a listing of the resource.
Display a listing of the resource .