envant/laravel-model-mutator

Load relations and append attributes from request query

1.1.4 2021-03-12 11:15 UTC

This package is auto-updated.

Last update: 2021-07-12 11:56:50 UTC


README

Packagist StyleCI GitHub

Load relations and append attributes from request query

Installation

Install package through Composer

$ composer require envant/laravel-model-mutator

Basic usage

Add Envant\ModelMutator\AllowedQueryMutationsTrait trait to your model

Including relations based on a request: /?include=first_relation,second_relation:

$model->allowedLoads([
'firstRelation',
'secondRelation',
]);

Count relations based on a request: /?counts=first_relation,second_relation:

$model->allowedCounts([
'firstRelation',
'secondRelation',
]);

Appending attributes to a query: /?append=first_attribute,second_attribute

$model->allowedAppends([
'firstAttribute',
'secondAttribute',
]);

Make attributes visible to a query: /?visible=first_attribute,second_attribute

$model->allowedVisible([
'firstAttribute',
'secondAttribute',
]);

Make attributes hidden to a query: /?hidden=first_attribute,second_attribute

$model->allowedHidden([
'firstAttribute',
'secondAttribute',
]);

Security

If you discover any security related issues, please email davidnadejdin@gmail.com instead of using the issue tracker.

License

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

Related packages