samedi 2 avril 2016

Call to a member function paginate() on array

I am working with Laravel5.0 . I want to add paginate() to the following function of my controller part.

public function index()
{
    try{
        $val=DB::connection()->getDatabaseName();
        if(DB::connection()->getDatabaseName()) {
            //$bRecord = DB::table('bills')->orderBy('Date', 'desc')->paginate(4);

            $bRecord = DB::table('bills')
                ->join('clients', 'bills.ClientID', '=', 'clients.ClientID')
                ->select('bills.ReceiptID', 'bills.ClientID', 'bills.Paid', 'bills.Date','bills.ReceivedBy',
                    'clients.ClientName')
                ->get();

            return view('bills.billRecord')->with('bRecord', $bRecord);
        }else{
            $er="/connection status: database error";
            return view('home')->with('error',$er);         //'error' is passed to home
        }
    }catch (\Exception $e){
        $er="/connection status: database error";
        return view('home')->with('error',$er);
    }

}

if I add paginate here, it shows error. "Call to a member function paginate() on array"

$bRecord = DB::table('bills')
                ->join('clients', 'bills.ClientID', '=', 'clients.ClientID')
                ->select('bills.ReceiptID', 'bills.ClientID', 'bills.Paid', 'bills.Date','bills.ReceivedBy',
                    'clients.ClientName')
                ->get()->paginate(4);

How can I use paginate() here?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire