Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

asadali007's avatar

Tinker issue

I already defined a Book model but i don't know this error come

PHP Error:  Class "Book" not found in /Applications/MAMP/htdocs/laravel/Test-Laravel-Migrations-maineval()'d code on line 1
0 likes
4 replies
asadali007's avatar

when i run this command on tinker this error have come

>>> $book=Book::first();
PHP Error:  Class "Book" not found in /Applications/MAMP/htdocs/laravel/Test-Laravel-Migrations-maineval()'d code on line 1

asadali007's avatar
BadMethodCallException with message 'Method Illuminate\Database\Eloquent\Collection::delete does not exist.'

MohamedTammam's avatar

Run that command before using the model.

use App\Models\Book

And make sure that Book model exists in the correct place.

Snapey's avatar

i don't understand this error

Class "Book" not found in /Applications/MAMP/htdocs/laravel/Test-Laravel-Migrations-maineval()'d code on line 1

does the path to your project contain some non ascii characters?

have you tried running composer dump?

Please or to participate in this conversation.