$projects=Project::with()
->withCount()
->orderBy('lift_at', 'desc')
->get()
->map(function ($item, $index) {
$item['ranking'] = $index + 1;
return $item;
})->where('user_id',Auth::id());
$projects=$this->paginate($projects, 10);
public function paginate($items, $perPage = 15, $page = null, $options = [])
{
$page = $page ?: (Paginator::resolveCurrentPage() ?: 1);
$items = $items instanceof Collection ? $items : Collection::make($items);
return new LengthAwarePaginator($items->forPage($page, $perPage), $items->count(), $perPage, $page, $options);
}