Download the PHP package a1dbox/laravel-model-accessor-builder without Composer
On this page you can find all versions of the php package a1dbox/laravel-model-accessor-builder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download a1dbox/laravel-model-accessor-builder
More information about a1dbox/laravel-model-accessor-builder
Files in a1dbox/laravel-model-accessor-builder
Package laravel-model-accessor-builder
Short Description You can build query on model accessor. Sort or filter by accessor, and at the same time it's a regular model accessor
License MIT
Homepage https://github.com/A1DBox/laravel-model-accessor-builder
Informations about the package laravel-model-accessor-builder
Laravel Model Accessor Builder
You can build query on model accessor. Sort or filter by accessor, and at the same time it's a regular working accessor
Installation
You can install the package via composer:
Usage
Use the HasAccessorBuilder
trait in your model to provide work of accessor builder:
Create Accessor for attribute
Laravel 8.x accessor defining style
As example, code above will do same as this one, when resolving accessor value:
Example #1
Here, the full_name
attribute contained in model $attributes
after query
And when using accessor ->full_name
, the value will be taken from $attributes
SQL Query executed:
Example #2
Here, the full_name
attribute NOT contained in $attributes
variable of model, and
when using accessor $user->full_name
, the value will be built from model $attributes
SQL Query executed:
Example #3
Get all users ordered by full_name
Example #4
Filter users by full_name
You can pass array to withAccessor
method
Testing
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
- A1DBox
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-model-accessor-builder with dependencies
ext-pdo Version *
ext-json Version *
illuminate/database Version >=8
spatie/laravel-package-tools Version ^1.9.2