mt-settings/laravel-settings

A simple settings management system for Laravel applications with RTL support

v1.0.0 2025-05-08 10:27 UTC

This package is auto-updated.

Last update: 2025-06-08 10:46:49 UTC


README

A simple and elegant settings management system for Laravel applications.

Laravel Settings License Version

โœจ Features

  • ๐Ÿš€ Easy to install and use
  • ๐Ÿ”’ Secure and optimized for performance
  • ๐Ÿ’พ Cached settings for better performance
  • ๐Ÿงฉ Organized settings by categories
  • ๐Ÿ”„ Simple API to get/set settings in your application

๐Ÿ“ฆ Installation

You can install the package via composer:

composer require mt-settings/laravel-settings

Manual Installation

  1. Publish the configuration:
php artisan vendor:publish --tag=laravel-settings-config
  1. Publish the migrations:
php artisan vendor:publish --tag=laravel-settings-migrations
  1. Run the migrations:
php artisan migrate

๐Ÿ“ Usage

In Controllers

use MtSettings\LaravelSettings\Facades\Settings;

// Get a setting with a default value
$siteName = Settings::get('site_name', 'Default Site Name');

// Set a setting
Settings::set('maintenance_mode', true);

// Check if a setting exists
if (Settings::has('meta_title')) {
    // Do something
}

// Get all settings
$allSettings = Settings::getAll();

// Clear settings cache
Settings::clearCache();

In Blade Templates

{{-- Get a setting with a default value --}}
<title>{{ Settings::get('site_name', config('app.name')) }}</title>

{{-- Check if a setting exists and use it --}}
@if(Settings::has('meta_description'))
    <meta name="description" content="{{ Settings::get('meta_description') }}">
@endif

{{-- Use a setting with a condition --}}
@if(Settings::get('maintenance_mode', false))
    <div class="alert alert-warning">
        The site is currently in maintenance mode
    </div>
@endif

Admin Panel

The package includes a complete admin panel for managing settings. By default, it's accessible at:

/admin/settings

You can customize the route prefix and middleware in the configuration file.

โš™๏ธ Configuration

You can customize the package behavior by modifying the published configuration file:

// config/settings.php

return [
    'route_prefix' => 'admin',
    'middleware' => ['web', 'auth'],
    // ...
];

๐Ÿ“‹ Available Settings

The package comes with predefined settings categories:

Category Settings
General site_name, items_per_page, maintenance_mode
SEO meta_title, meta_description, meta_keywords
Contact contact_email, phone_number, address
Social Media facebook_url, twitter_url, instagram_url, linkedin_url
Advanced cache_enabled, cache_expiration, google_analytics_id, custom_header_scripts

General

  • site_name: Your site name
  • items_per_page: Default number of items per page
  • maintenance_mode: Enable/disable maintenance mode

SEO

  • meta_title: Default meta title
  • meta_description: Default meta description
  • meta_keywords: Default meta keywords

Contact

  • contact_email: Contact email address
  • phone_number: Contact phone number
  • address: Physical address

Social Media

  • facebook_url: Facebook page URL
  • twitter_url: Twitter profile URL
  • instagram_url: Instagram profile URL
  • linkedin_url: LinkedIn profile URL

Advanced

  • cache_enabled: Enable/disable settings cache
  • cache_expiration: Cache expiration time in seconds
  • google_analytics_id: Google Analytics tracking ID
  • custom_header_scripts: Custom scripts to include in the header

๐ŸŽจ Customization

Views

If you published the views, you can customize them at:

resources/views/vendor/laravel-settings

Translations

The package supports translations through Laravel's localization system. To publish translations:

php artisan vendor:publish --tag=laravel-settings-translations

๐Ÿงช Testing

composer test

๐Ÿ“„ License

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