Download the PHP package sdavis1902/eloquent-vars without Composer
On this page you can find all versions of the php package sdavis1902/eloquent-vars. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sdavis1902/eloquent-vars
More information about sdavis1902/eloquent-vars
Files in sdavis1902/eloquent-vars
Package eloquent-vars
Short Description Add ability to save additional fields or Vars on a Laravel model without a specific db column for it
License MIT
Homepage https://github.com/sdavis1902/eloquent-vars
Informations about the package eloquent-vars
Eloquent Vars
Add ability to save additional fields or Vars on a Laravel model without a specific db column for it
Install
Via Composer
Add the service provider ( not required for 5.5 )
Publish and run migration
Usage
Add the trait to your model
Now you can do the following...
Note, the above require the model object to have an id, so will need to have been written to the database already.
If you want use a more eloquent method, you can use the following. Additionally, the following method will work on new model instances that have not been inserted yet.
Additionally, the trait includes a relationship for the vars which allows you to eager load. The above method of accessing vars uses this relationship, so you can eager load and then use the vars like above.
Note, values are stored as a string, so if you save an int, when you get it, it will be a string.
Contributing
Please see CONDUCT for details.
Credits
- Scott Davis
- All Contributors
License
The MIT License (MIT). Please see License File for more information.