Help to figure out where to shove the method ->paginate(10) .
This is a query to the database:
public function getAllNews() { return $this->orderBy('seriatim', 'desc')->where(['active' => 1])->get(); } This is a call to the method of receiving all news in the controller:
$Allnews = $news->getAllNews()->toArray(); $i = 0; foreach ($Allnews as $value) { $value['created_at'] = Carbon::createFromFormat('Ymd H:i:s', $value['created_at'])->format('dmY / H:i:s'); $Allnews[$i]['date'] = $value['created_at']; $i++; } After calling the getAllNews() method, I use, foreach to add the key with the necessary date and time format to the same array.
Well and then, I create a variable for the view:
$data = [ 'Allnews' => $Allnews, 'MainMenu' => $menu->getMainOptions()->toArray(), 'SubMenu' => $subm->getSubOptions()->toArray(), ]; How to paginate news here?