Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shirokovnv/model-reflection
The package for reflecting laravel eloquent model properties, relations and scopes.
https://github.com/shirokovnv/model-reflection
laravel model package php reflection
Last synced: 1 day ago
JSON representation
The package for reflecting laravel eloquent model properties, relations and scopes.
- Host: GitHub
- URL: https://github.com/shirokovnv/model-reflection
- Owner: shirokovnv
- License: mit
- Created: 2021-01-06T20:38:42.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-08-18T15:03:02.000Z (over 2 years ago)
- Last Synced: 2024-11-08T20:09:25.719Z (10 days ago)
- Topics: laravel, model, package, php, reflection
- Language: PHP
- Homepage: https://packagist.org/packages/shirokovnv/model-reflection
- Size: 67.4 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Changelog: changelog.md
- Contributing: contributing.md
- License: license.md
Awesome Lists containing this project
README
# ModelReflection
![ci.yml][link-ci]
[![Latest Version on Packagist][ico-version]][link-packagist]
[![Total Downloads][ico-downloads]][link-downloads]The package allows you to reflect properties and methods of the model and save received information in form of a JSON schema.
## Installation
Via Composer
``` bash
$ composer require shirokovnv/model-reflection
```## Usage
This package is based on Doctrine/DBAL
Once installed you can do stuff like this:
```php
$user_schema = ModelReflection::reflect(\App\Models\User::class);
```this will return ReflectedModel containing information about:
- class name
- table name
- fields
- relations
- table foreign keys
- scopesor you can do:
```php
$user_schema->toArray();
```
this will return an associative array for JSON representation.## Change log
Please see the [changelog](changelog.md) for more information on what has changed recently.
## Testing
``` bash
$ composer test
```## Contributing
Please see [contributing.md](contributing.md) for details and a todolist.
## Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
## Credits
- [Nickolai Shirokov][link-author]
- [All Contributors][link-contributors]## License
MIT. Please see the [license file](license.md) for more information.
[ico-version]: https://img.shields.io/packagist/v/shirokovnv/model-reflection.svg?style=flat-square
[ico-downloads]: https://img.shields.io/packagist/dt/shirokovnv/model-reflection.svg?style=flat-square[link-ci]: https://github.com/shirokovnv/model-reflection/actions/workflows/ci.yml/badge.svg
[link-packagist]: https://packagist.org/packages/shirokovnv/model-reflection
[link-downloads]: https://packagist.org/packages/shirokovnv/model-reflection
[link-author]: https://github.com/shirokovnv
[link-contributors]: ../../contributors