PHP Classes

Laravel Settings Model: Store and retrieve settings for model objects

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 39 All time: 10,923 This week: 455Up
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: 38 packages by
Country: Egypt Egypt
Age: 31
All time rank: 257726 in Egypt Egypt
Week rank: 288 Up4 in Egypt Egypt Up
Innovation award
Innovation award
Nominee: 22x

Documentation

[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 folder image Files (9)  
File Role Description
Files folder imagesrc (3 files, 2 directories)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (9)  /  src  
File Role Description
Files folder imagedatabase (1 directory)
Files folder imageTraits (2 files)
  Plain text file CurrencyServiceProvider.php Class Class source
  Plain text file hasSettings.php Class Class source
  Plain text file Settings.php Class Class source

  Files folder image Files (9)  /  src  /  database  
File Role Description
Files folder imagemigrations (1 file)

  Files folder image Files (9)  /  src  /  database  /  migrations  
File Role Description
  Plain text file settings.stub Class Class source

  Files folder image Files (9)  /  src  /  Traits  
File Role Description
  Plain text file Relationships.php Class Class source
  Plain text file Scopes.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:39
This week:0
All time:10,923
This week:455Up