laravel 模型信息 是 模型信息 的一个包,用于获取有关 Laravel 中所有模型的信息项目。如果你正在构建需要以编程方式检查模型的功能,此包会很有帮助。【相关推荐:模型信息】
例如,你可以访问许多重要的详细信息,如数据库表名、属性、关系等:
use SpatieModelInfoModelInfo; $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
我在这个包中注意到的一个很棒的功能是获取项目中的所有模型:
// 返回所有应用模型的集合 $models = ModelFinder::all();
要了解更多信息,请查看 Freek Van der Herten 的文 模型信息。 你可以在 模型信息的 GitHub 上获取文档和源代码。
原文地址:https://laravel-news.com/laravel-model-info译文地址:https://learnku.com/laravel/t/71822
更多编程相关知识,请访问:模型信息!!
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END