An invoice form is writing issued_on and getting a string back. You open the model, then the migration, then the provider, and you still are not sure whether the cast is registered. model:show prints the model the way the framework sees it: columns, casts, relations, observers, and the table name, on one screen.
Run it against the real class. Invoice is enough when the model lives in App\Models. Pass the fully qualified name when it does not.
01 What it does
The attributes table lists the column, the PHP type, and the cast. A missing column means the migration has not been run. A missing cast means the controller will not get the type you expect. The relations table names the related model and the foreign key, which is the check to make before you add an eager load: the name in with() has to match the method.
php artisan model:show App\Models\Invoice --json--json is the version to diff in a review. A teammate can see that issued_on is a date and that lines() is a HasMany, without scrolling a terminal.
02 Gotchas
- The argument is the class, not the table.
model:show invoiceswill not findApp\Models\Invoice. - A relation that points at the wrong foreign key still looks fine in the method. This command is where the key is visible.
--jsonfollows the database you are connected to. A local database that has not been migrated will disagree with production.- Observers registered in a provider appear here. A closure inside
booted()does too, once the application has booted, which this command does.
03 Related
Models that match the domain is the lesson this command is checking. Casts, enums and custom casters is what you open when the cast column is wrong.