Download the PHP package naoray/eloquent-model-analyzer without Composer
On this page you can find all versions of the php package naoray/eloquent-model-analyzer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download naoray/eloquent-model-analyzer
More information about naoray/eloquent-model-analyzer
Files in naoray/eloquent-model-analyzer
Package eloquent-model-analyzer
Short Description Helpful methods to gain more information about eloquent model classes.
License MIT
Informations about the package eloquent-model-analyzer
eloquent-model-analyzer
Analyzing an Eloquent Model for its relations and columns can be overwhelming. This little library aims to make it as simple as possible.
You probably wonder why you would ever need to analyze your Models at runtime?! All scenarios I can think of are related to analyzing the codebase to generate some code bits. Here are some scenarios where this might come in handy:
- automatically create factories for your models as shown in laravel-prefill-factory or factory-generator
- it could be use to create something like the
trace
command in laravel-shift/blueprint
Install
composer require naoray/eloquent-model-analyzer
Usage
Getting all relations of a Model
There are three different strategies for getting all relation methods of an Eloquent Model:
- checking the return types of the methods
- extracting the return types from the doc method
- call the method directly and check the instance of what is returned
The RelationMethod
Class forwards all method calls which aren't present on the class directly to the underlying ReflectionMethod
class.
Getting all Columns of a Model
The Column
class forwards all method calls which aren't present on the class directly to the underlying DBAL\Schema\Column
Class.
Testing
Run the tests with:
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.
All versions of eloquent-model-analyzer with dependencies
illuminate/support Version ^8.24.0|^9.0|^10.0
doctrine/dbal Version ^2.6|^3.0