Download the PHP package netkod-bilisim/laravel-model-settings-bag without Composer
On this page you can find all versions of the php package netkod-bilisim/laravel-model-settings-bag. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download netkod-bilisim/laravel-model-settings-bag
More information about netkod-bilisim/laravel-model-settings-bag
Files in netkod-bilisim/laravel-model-settings-bag
Package laravel-model-settings-bag
Short Description You can add simple and flexible, single or multiple settings to your Laravel models.
License MIT
Informations about the package laravel-model-settings-bag
Laravel Model Settings Bag
Introduction
You can add simple and flexible, single or multiple settings to your Laravel models.
Requirements
- PHP >= 7.4
Install
Integration
Single Setting
1. Add a JSON settings field to your model's migration.
_create_userstable.php
2. Use the trait NetkodBilisim\LaravelModelSettingsBag\ModelHasSettingsBag
within your model.
User.php
Multiple
1. Add a JSON settings field to your model's migration.
_create_user_template_settingstable.php
2. Use the trait NetkodBilisim\LaravelModelSettingsBag\ModelHasSettingsBag
within your other setting model.
User TemplateSetting.php
3. Use the trait NetkodBilisim\LaravelModelSettingsBag\ModelHasSettingsBag
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 laravel-model-settings-bag with dependencies
ext-json Version *
illuminate/database Version >=5.5
illuminate/support Version >=5.5