Looking to hire Laravel developers? Try LaraJobs

laravel-model-utils maintained by ivanomatteo

Description
Extract info from models
Author
Last update
2023/10/09 07:31 (dev-dependabot/github_actions/stefanzweifel/git-auto-commit-action-5)
License
Downloads
39

Comments
comments powered by Disqus

Extract attributes metadata from model

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.