Reputation: 1990
I tried querying the database this way but it returns the error.
latest() not found.
DailyReport::get()->latest()->paginate(10)
I want it to return all the DailyReports with pagination.
Upvotes: 2
Views: 5500
Reputation:
The latest()
method is short for orderBy('created_at', 'desc')
. You can achieve what you want by:
$latest_daily_reports = DailyReport::latest()->paginate(10);
You can also change the column latest()
orders by.
->latest('your_column_name');
Upvotes: 5
Reputation: 31
This is because get()
.
You should try DailyReport::latest()->paginate(10)
Upvotes: 0