awobaz / eloquent-auto-append
Automatically append accessors to model serialization
Installs: 814
Dependents: 0
Suggesters: 11
Security: 0
Stars: 14
Watchers: 2
Forks: 0
Open Issues: 1
Requires
- php: >=7.1
- illuminate/cache: ~5.4|~6.0|~7.0|~8.0|~9.0|~10.0|~11.0
- illuminate/console: ~5.4|~6.0|~7.0|~8.0|~9.0|~10.0|~11.0
- illuminate/database: ~5.4|~6.0|~7.0|~8.0|~9.0|~10.0|~11.0
- illuminate/support: ~5.4|~6.0|~7.0|~8.0|~9.0|~10.0|~11.0
Requires (Dev)
- fakerphp/faker: ^1.19
- laravel/laravel: ~5.4|~6.0|~7.0|~8.0|~9.0|~10.0|~11.0
- phpunit/phpunit: ~5.4|~6.0|~7.0|~8.0|~9.0|~10.0|~11.0
Suggests
- awobaz/blade-active: Blade directives for the Laravel 'Active' package
- awobaz/compoships: Multi-columns relationships for Laravel 5's Eloquent
- awobaz/eloquent-mutators: Reusable accessors/mutators (getters/setters) for Laravel 5's Eloquent
- awobaz/syntactic: Syntactic sugar for named and indexed parameters call.
README
Eloquent Auto Append automatically appends your accessors to model serialization without having you to explicitly specify them in the $appends
array.
Related discussions:
- How to always append attributes to Laravel Eloquent model?
- Why is my Laravel Eloquent accessor not showing up in the response?
Installation
The recommended way to install Eloquent Auto Append is through Composer
$ composer require awobaz/eloquent-auto-append
Note: Eloquent Auto Append requires Laravel 5.4+.
Usage
Using the Awobaz\AutoAppend\Database\Eloquent\Model
class
Simply make your model class derive from the Awobaz\AutoAppend\Database\Eloquent\Model
base class. The Awobaz\AutoAppend\Database\Eloquent\Model
extends the Eloquent
base class without changing its core functionality.
Using the Awobaz\AutoAppend\AutoAppend
trait
If for some reasons you can't derive your models from Awobaz\AutoAppend\Database\Eloquent\Model
, you may take advantage of the Awobaz\AutoAppend\AutoAppend
trait. Simply use the trait in your models.
Disable Auto Append
You may disable Auto Append on a model by setting it's property $autoAppend
to false
protected $autoAppend = false;
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Unit Tests
In order to run the test suite, install the development dependencies:
$ composer install --dev
Then, run the following command:
$ vendor/bin/phpunit
Authors
- Claudin J. Daniel - Initial work
Sponsored by
- Awobaz - Web/Mobile agency based in Montreal, Canada
License
Eloquent Auto Append is licensed under the MIT License.