mt-settings/laravel-settings 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mt-settings/laravel-settings

最新稳定版本:v1.0.0

Composer 安装命令:

composer require mt-settings/laravel-settings

包简介

A simple settings management system for Laravel applications with RTL support

README 文档

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.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-08