Markofly / laravel-settings by markofly

Larevel 5 settings
24
0
1
Package Data
Maintainer Username: markofly
Maintainer Contact: marko.murumaa@gmail.com (Marko Murumaa)
Package Create Date: 2017-01-12
Package Last Update: 2017-01-29
Language: PHP
License: MIT
Last Refreshed: 2025-04-25 15:01:52
Package Statistics
Total Downloads: 24
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 1
Total Forks: 0
Total Open Issues: 0

Laravel settings

Packagist Packagist Packagist

laravel-settings is Laravel 5 package.

Installation

Using composer

$ composer require markofly/laravel-settings

Add the service provider to config/app.php

'providers' => [
  ...
  Markofly\Settings\SettingsServiceProvider::class,
],

Add the facade to config/app.php

'aliases' => [
  ...
  'Settings' => \Markofly\Settings\Facades\Settings::class,
],

Publish config and migration files

$ php artisan vendor:publish --provider="Markofly\Settings\SettingsServiceProvider"
$ php artisan migrate

Usage

In config/markofly/settings.php create default settings.

<?php

return [
    ...
    'fields' => [
            'site_name' => [
                'default' => 'Laravel 5',
            ],
            ...
        ],
];

Get setting value

<?php
Settings::get('site_name');
Settings::get('site_name', 'Default value');

Save settings to database

<?php
Settings::save('site_name', 'Laravel 5');

Get all fields from config and database

<?php
Settings::getAllSettings();

This returns:

 [
  'site_name' => [
    'value' => null             // Value stored in database
    "default' => 'Laravel 5'    // Default value in config
    'group' => [                // group settings in config
      'label' => 'Site settings'
      'slug' => 'site-settings'
    ]
  ]
]

License

The MIT License (MIT). Please see License File for more information.