Download the PHP package cklmercer/laravel-model-settings without Composer
On this page you can find all versions of the php package cklmercer/laravel-model-settings. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
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 Cklmercer\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 ^6.0 || ^7.0 || ^8.0
illuminate/support Version ^6.0 || ^7.0 || ^8.0