mt-settings / laravel-settings
A simple settings management system for Laravel applications with RTL support
Requires
- php: ^8.1|^8.2
- illuminate/support: ^10.0|^11.0|^12.0
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.
โจ 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
- Publish the configuration:
php artisan vendor:publish --tag=laravel-settings-config
- Publish the migrations:
php artisan vendor:publish --tag=laravel-settings-migrations
- 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.