📜  在同一页面 laravel 中使用多个分页 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:09.825000             🧑  作者: Mango

代码示例1
// in controller 
$newEvents = Events::where('event_date', '>=', Carbon::now()->startOfDay())
    ->orderBy('event_date')
    ->paginate(15,['*'], 'newEvents');

$oldEvents = Events::where('event_date', '<', Carbon::now()->startOfDay())
    ->orderBy('event_date', 'desc')
    ->paginate(15,['*'], 'oldEvents');

//use in view
    
// some code to display $newEvents
{!! $newEvents->render() !!}

// some code to display $oldEvents
{!! $oldEvents->render() !!}