Laravel Settings Model: Store and retrieve settings for model objects

Recommend this page to a friend!
  Info   Documentation   View files (9)   Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2020-03-07 (5 months ago) Not yet rated by the usersTotal: 31 All time: 9,942 This week: 251
Version License PHP version Categories
laravel-settings 1.0Custom (specified...5PHP 5, Databases, Libraries, Design P...
Description Author

This package can store and retrieve settings for Laravel model objects.

It provides a trait that can be used by Laravel model class, so the values of settings for those model class objects are retrieved from settings model objects.

The package also provides means to create, read, update and delete settings objects.

Innovation Award
PHP Programming Innovation award nominee
March 2020
Number 6
Many applications need to deal with objects that represent important entities that the applications use, like for instance, an e-commerce product that is sold on a site. These objects are usually stored using model classes.

Sometimes it is necessary to customize the behavior of model objects according to application settings that may even be customized for each application user.

The package makes it easier to implement model classes that can be customized with settings model objects.

Manuel Lemos
Picture of Moamen Eltouny
  Performance   Level  
Name: Moamen Eltouny <contact>
Classes: 11 packages by
Country: Egypt Egypt
Innovation award
Innovation award
Nominee: 5x

Details

[RaggiTech] Laravel >= 6.0 - Settings/Info.

Latest Stable Version Total Downloads License

Laravel Settings/Info provides a quick and easy methods (General/Model).

Example:

// Create/Update Setting
$page->setSetting('facebook_url', 'https://www.facebook.com/RaggiTech');

// Retrieve Setting's Value
echo $page->setting('facebbok_url');	// https://www.facebook.com/RaggiTech

Install

Install the latest version using Composer:

$ composer require raggitech/laravel-settings

then publish the migration & migrate

$ php artisan vendor:publish --tag=laravel-settings
$ php artisan migrate

Usage

// An Example : (Page Model)
// Using HasSettings in Page Model
...
use RaggiTech\Laravel\Settings\HasSettings;

class Page extends Model
{
    use hasSettings;
...

<a name="gs"></a>

General Settings

<a name="gs_cu"></a>

Create / Update Setting's Value

use RaggiTech\Laravel\Settings\Settings;

// Single
Settings::set('website_status', true);

// Multi
Settings::set([
	'website_status' => false,
	'website_off_message' => 'OFFLINE!',
]);

<a name="gs_get"></a>

Retrieve Value & All

use RaggiTech\Laravel\Settings\Settings;

// Single
$setting = Settings::get('website_keywords'); // raggitech, raggi, ...

// All
$settings = Settings::get(); // => All General Setting

<a name="gs_dc"></a>

Delete & Clear

use RaggiTech\Laravel\Settings\Settings;

// Delete/Remove
Settings::remove('website_keywords');

// Clear
Settings::clear(); // Clearing the general settings

<a name="m"></a>

Model Settings

<a name="m_cu"></a>

Create / Update Setting's Value

// Single
$page->setSetting('status', true);

// Multi
$page->setSettings([
	'website_url'    => 'https://raggitech.com',
	'facebook_url'   => 'https://www.facebook.com/RaggiTech',
	'twitter_url'    => 'https://www.twitter.com/RaggiTech',
	'instagram_url'  => 'https://www.instagram.com/raggitech',
]);

<a name="m_get"></a>

Retrieve Value & All

// Single
$setting = $page->setting('website_url');

// All
$settings = $page->settings;

<a name="gs_dc"></a>

Delete & Clear

// Delete/Remove
$page->removeSetting('instagram_url');

// Clear
$page->clearSettings();// Clearing page's settings

<a name="scopes"></a>

Scopes

// Get every element has no Settings.
$p1 = Page::withoutSettings()->get();

// Get every element has setting (status).
$p2 = Page::withSettings('status')->get();

// Get every element has setting (status == true).
$p3 = Page::withSettingsValue('status', true)->get();

// Get every element has [facebook or twitter or all] settings.
$p4 = Page::withAnySettings(['facebook', 'twitter'])->get();

License

MIT license

  Files  
File Role Description
src (3 files, 2 directories)
composer.json Data Auxiliary data
LICENSE Lic. License text
README.md Doc. Documentation

  Files  /  src  
File Role Description
database (1 directory)
Traits (2 files)
   CurrencyServiceProvider.php Class Class source
   hasSettings.php Class Class source
   Settings.php Class Class source

  Files  /  src  /  database  
File Role Description
migrations (1 file)

  Files  /  src  /  database  /  migrations  
File Role Description
   settings.stub Class Class source

  Files  /  src  /  Traits  
File Role Description
   Relationships.php Class Class source
   Scopes.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:31
This week:0
All time:9,942
This week:251

For more information send a message to info at phpclasses dot org.