When I run the known tinder CRUD Commands in Laravel 8, they aren’t working
What I ran was the Create and Find commands
$user = new AppUser;
AppUser::all();
But they aren’t working, I knew that in Laravel 8, the Model file is in this path AppModels ‘File’, and I tried to modify the creating code from $user = new AppUser;
to $user = new AppModelsUser;
But also this doesn’t work and the error I get is
PHP Fatal error: Class 'App/Models/User' not found in Psy Shell code on line 1
So generaty what are the changes to tinker in Laravel 8
Note: I also tried to clear the cache and clear the composer and it didn’t solve the problem.
Advertisement
Answer
In Laravel 8, you should do it this way:
$user = new AppModelsUser; $users = AppModelsUser::all();
or above the controller class declaration, do
use AppModelsUser;
then in the method, you can do
$user = new User; $users = User::all();