Route::get('/', function () {
return view('posts', [
'posts' => User::latest()->get()
]);
});
I can't use latest, because it says method not found.
CodePudding user response:
Try this
use App\Models\User;
Route::get('/', function () {
return view('posts', [
'posts' => User::latest()->get();
]);
});
CodePudding user response:
Make sure you use the User model correctly, like this:
use App\Models\User;
Route::get('/', function () {
return view('posts', [
'posts' => User::latest()->get();
]);
});