I wished create model call the laravel artisan tinker.
so I try execute php tinker .. but App\User command was occurred error.
I don't know. what should I do?
My development enviroment vagrant php 8.* laravel 8.*
enter image description here enter image description here
>>> $user = App\User::create (['name' => 'rin', 'email' => 'rin@test.com', 'password' => bcrypt('123456')]);
PHP Error: Class "App\User" not found in Psy Shell code on line 1
>>> App\User::find(1)->articles()->create(['title' => 'First article', 'content' => 'First content']);
PHP Error: Class "App\User" not found in Psy Shell code on line 1
In Laravel 8 all models sit inside a Models
folder by default.
So you need to replace App\User
with App\Models\User
.
Docs: https://laravel.com/docs/8.x/structure#the-models-directory