Laravel Model Information is a package for Spatie to get information about all model items in Laravel. This package is helpful if you are building functionality that requires you to check the model programmatically. [Related recommendations: laravel video tutorial]
For example, you can access many important details such as database table names, properties, relationships, etc.:
use Spatie\ModelInfo\ModelInfo; $model = ModelInfo::for(Post::class); $model->attributes; $model->relations; // etc. // 属性和关系是集合 $model->attributes->first()->name; // title $model->attributes->first()->type; // string(255) $model->attributes->first()->phpType; // string
I am A great feature noticed in this package is getting all the models in the project:
// 返回所有应用模型的集合 $models = ModelFinder::all();
For more information, check out Freek Van der Herten's article Getting information about all the models in your Laravel app. You can get the documentation and source code on GitHub at spatie/laravel-model-info.
Original address: https://laravel-news.com/laravel-model-info
Translation address: https://learnku.com/laravel/t/71822
For more programming-related knowledge, please visit: Programming Video! !
The above is the detailed content of Laravel extension recommendation: Get model information tool 'laravel-model-info'. For more information, please follow other related articles on the PHP Chinese website!