dimanche 1 mars 2020

Laravel pagination with custom array

i am new to laravel.i am working with database:paginnation

$postData = DB::table('posts')->paginate(1);
return view('posts.index', ['users' => $users]);

Above code working fine with pagination and display correct pagination But now my blog app doesn't require this type

I pass data to view something like this

 $postData = DB::select('SELECT * FROM posts')->paginate(2);

 $pageData = array(
    "title"=>"Post Index",            
     "postData" => $postData
 );
 return view('posts.index')->with('pageData',$pageData);

which will cause

Call to a member function paginate() on array

My laravel version is 5.7



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire