get method returns a collection. I think you should paginate it before calling get.
$files = $files->latest('created_at')->paginate();
$files = File::where('campaign_id', $id);
if ($month = request('month')) {
$files->whereMonth('created_at', Carbon::parse($month)->month);
}
if ($year = request('year')) {
$files->whereYear('created_at', $year);
}
$files = $files->get()->sortByDesc('created_at');
I tried adding it on the first line but get
Too few arguments to function Illuminate\Support\Collection::get(), 0 passed, at least 1 expected
I tried adding it on the last line and get
Method Illuminate\Database\Eloquent\Collection::paginate does not exist.
get method returns a collection. I think you should paginate it before calling get.
$files = $files->latest('created_at')->paginate();
Please or to participate in this conversation.