Monday, July 15, 2024
HomePHPGet Useful Details about Fashions in Laravel

Get Useful Details about Fashions in Laravel

Laravel Mannequin Information is a bundle by Spatie to get info on all of the fashions in your Laravel mission. This bundle is useful when you’re constructing performance the place it’s worthwhile to programmatically examine fashions.

For instance, you’ll be able to entry many vital particulars just like the database desk identify, attributes, relationships, and extra:

1use SpatieModelInfoModelInfo;


3$mannequin = ModelInfo::for(Publish::class);



6// and so on.


8// Attributes and relations are collections

9$mannequin->attributes->first()->identify; // title

10$mannequin->attributes->first()->kind; // string(255)

11$mannequin->attributes->first()->phpType; // string

One of many unbelievable options I observed on this bundle is getting all of the fashions in your mission:

1// Returns a set of all of your app's fashions

2$fashions = ModelFinder::all();

To be taught extra, take a look at Freek Van der Herten’s article Getting details about all of the fashions in your Laravel app. You will get documentation and the supply code on GitHub at spatie/laravel-model-info.



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments