ivanomatteo / model-utils
Extract info from models
Fund package maintenance!
ivanomatteo
Installs: 1 502
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 3
Forks: 0
Open Issues: 3
Requires
- php: ^8.0
- barryvdh/reflection-docblock: ^2.0.6
- doctrine/dbal: ^2.6 || ^3
- illuminate/contracts: ^8.73|^9.0
- phpdocumentor/type-resolver: ^1.1.0
- spatie/laravel-package-tools: ^1.9.2
Requires (Dev)
- nunomaduro/collision: ^5.10
- nunomaduro/larastan: ^1.0
- orchestra/testbench: ^6.22
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2023-10-09 05:31:10 UTC
README
This package provide a simple way to retrive usefull metadata from laravel models
- find all models inside a psr-4 directory structure
- retrieve all columns and metadata from database
- retrieve indexes metadata
- generate basic validation rules using metadata
- model type hinting removed, you can use https://github.com/barryvdh/laravel-ide-helper
Installation
You can install the package via composer:
composer require ivanomatteo/laravel-model-utils
Usage
use IvanoMatteo\ModelUtils\ModelUtils; dump(ModelUtils::findModels()); $mu = new ModelUtils(\App\User::class); dump('id visible:',$mu->isVisible('id')); dump('password visible:',$mu->isVisible('password')); dump($mu->getValidationRules()); dump($mu->getValidationRules(true)); //also for not fillable fields dump($mu->getMetadata());
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Ivano Matteo
- Thanks also to Barry vd. Heuvel for his libraries, i took some pices of code from ide helper
- All Contributors
License
The MIT License (MIT). Please see License File for more information.