ivanomatteo/model-utils

This package is abandoned and no longer maintained. The author suggests using the ivanomatteo/laravel-model-utils package instead.

Extract info from models

0.4.3 2022-05-10 09:02 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

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

License

The MIT License (MIT). Please see License File for more information.