Download the PHP package abdullahfaqeir/laravel-model-settings without Composer
On this page you can find all versions of the php package abdullahfaqeir/laravel-model-settings. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download abdullahfaqeir/laravel-model-settings
More information about abdullahfaqeir/laravel-model-settings
Files in abdullahfaqeir/laravel-model-settings
Package laravel-model-settings
Short Description Add simple yet flexible settings to your Laravel models.
License MIT
Informations about the package laravel-model-settings
laravel-model-settings
Simple yet flexible settings for your Laravel models.
Note: I will be updating this plugin in the near future to better match the API of the new cache()
helper method that has been introduced in Laravel 5.3
Installation
1.) Install via composer
2.) Add a JSON settings field to your model's migration.
_create_userstable.php
3.) Use the trait AbdullahFaqeir\ModelSettings\HasSettings
within your model.
User.php
Usage
1.) Get all of the model's settings.
2.) Get a specific setting.
3.) Add or update a setting.
4.) Determine if the model has a specific setting.
5.) Remove a setting from a model.
6.) Set the default settings for a new model.
If you define $defaultSettings
as an array property on your model, we will use its value as the default settings for
any new models that are created without settings.
User.php
7.) Specify the settings that are allowed.
If you define $allowedSettings
as an array property then only settings which match a value within
the $allowedSettings
array will be saved on the model.
User.php
8.) Using another method name other than settings()
If you prefer to use another name other than settings
, you can do so by defining a $mapSettingsTo
property. This simply maps calls to the method (such as config()
) to the settings()
method.
User.php
License
All versions of laravel-model-settings with dependencies
illuminate/database Version ^9.0|^10.0|^11.0
illuminate/support Version ^9.0|^10.0|^11.0