I've a project with an strange issue. For the same configuration if I run tinker on heroku like this, it will automatically load my classes without writing the use clause:
$ heroku run php artisan tinker
Psy Shell v0.11.12 (PHP 7.4.33 — cli) by Justin Hileman
>>> User::first()
[!] Aliasing 'User' to 'App\Models\User' for this Tinker session.
but if I do this locally on my dev machine, it doesn't work:
» php artisan tinker
Psy Shell v0.11.12 (PHP 7.4.33 — cli) by Justin Hileman
> User::first()
Error Class 'User' not found.
> use App\Model\User
> User::first()
= App\User {#5027
....
As you can see, is the same exact version in both places. I couldn't find much documentation on what is needed to make this work.
Now, inside your config/tinker.php, you'll find a key named alias, which can be used to alias certain classes by default.
Though files inside the app/ directory should be aliased automatically. But I don't know why it's ont the cae for you. You might want to try to refresh your composer autoloader with composer dump-autoload. Don't know if this helps.