laravel 模型信息 是 模型信息 的一個包,用于獲取有關 Laravel 中所有模型的信息項目。如果你正在構建需要以編程方式檢查模型的功能,此包會很有幫助?!鞠嚓P推薦:模型信息】
例如,你可以訪問許多重要的詳細信息,如數據庫表名、屬性、關系等:
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