Skip to content

Extract metadata from laravel models, generate basic validation rules, retrieve models from filesystem

License

Notifications You must be signed in to change notification settings

ivanomatteo/laravel-model-utils

Repository files navigation

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.

About

Extract metadata from laravel models, generate basic validation rules, retrieve models from filesystem

Resources

License

Security policy

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages