dimanche 17 janvier 2016

Unable to set pagination in [Laravel 5.1]

With the code below, what I wanted was paginate the query I created. But, when I try to add paginate it throws an error. I want to get only one tables data, so i am using table.* here, but it throws an error, but if i try to fetch specific columns like table.id, table.name etc, then it works perfect, so where i am wrong?

public function index()
{

    $query = Phones::join('manufacturers', 'manufacturers_id', '=', 'manufacturers.id');

    if ( Request::query('str') ) {
        $query->where('model', 'LIKE', '%'. Request::query('str') . '%')
    }

    $phones = $query->paginate(5, ['Phones.*']);                   //it throws error here,
    $phones = $query->paginate(5, ['Phones.id','Phones.name']);    //it works here,

    return View::make('phones.index')->with('phones', $phones);
} 

so in both of the above queries, if i try to use Phone.* then it throws error, but it works for Phone.id, etc.

What would should be the better idea to paginate this thing?

Please help me to sort out this issue.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire