Download the PHP package x-laravel/model-settings-bag without Composer
On this page you can find all versions of the php package x-laravel/model-settings-bag. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download x-laravel/model-settings-bag
More information about x-laravel/model-settings-bag
Files in x-laravel/model-settings-bag
Package model-settings-bag
Short Description Add simple but flexible multiple settings to your Laravel models.
License MIT
Informations about the package model-settings-bag
Laravel Str Facade TR Extend
Introduction
Add simple but flexible multiple settings to your Laravel models.
Requirements
PHP >=7.0. Other than that, this library has no requirements.
Installation
Integration
Single
1. Add a JSON settings field to your model's migration.
_create_userstable.php
2. Use the trait XLaravel\ModelSettingsBag\HasSettingsBag
within your model.
User.php
Multiple
1. Add a JSON settings field to your model's migration.
_create_user_theme_settingstable.php
2. Use the trait XLaravel\ModelSettingsBag\HasSettingsBag
within your other setting model.
UserThemeSetting.php
3. Use the trait XLaravel\ModelSettingsBag\HasSettingsBag
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
This package is open source software licensed under the MIT license.
All versions of model-settings-bag with dependencies
ext-json Version *
illuminate/database Version >=5.5
illuminate/support Version >=5.5