Laravel Model Info is a package by Spatie to get information on all the models in your Laravel project. This package is helpful if you're building functionality where you need to programmatically inspect models.
For example, you can access many important details like the database table name, attributes, relationships, and more:
1use Spatie\ModelInfo\ModelInfo;23$model = ModelInfo::for(Post::class);4$model->attributes;5$model->relations;6// etc.78// Attributes and relations are collections9$model->attributes->first()->name; // title10$model->attributes->first()->type; // string(255)11$model->attributes->first()->phpType; // string
One of the fantastic features I noticed in this package is getting all the models in your project:
1// Returns a collection of all your app's models2$models = ModelFinder::all();
To learn more, check out Freek Van der Herten's article Getting information about all the models in your Laravel app. You can get documentation and the source code on GitHub at spatie/laravel-model-info.