定制 alexusmai/easy-settings 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

alexusmai/easy-settings

Composer 安装命令:

composer require alexusmai/easy-settings

包简介

Laravel + Vue - easy settings for your application

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License

Easy Settings Vue App

The application is designed for convenient and fast work with simple data of your application.

For example, you need to place a phone number in the footer of your site. You can enter it directly into the HTML code, but if you need to change it, you'll have to dig into the code. And if you make a website to a client, then he will not even know how to change this number. Of course you can write your own CRUD's for all items ... or you can just use this package.

This package is suitable for storing such data as:

  • strings
  • numbers, phone numbers,
  • small blocks of text
  • Boolean types (true, false) ON / OFF

Also, if you have a multilingual site, then you will also be able to make your work easier, and save the required data in several languages.

Installation

Composer

composer require alexusmai/easy-settings

If you have Laravel 5.4 or earlier version, then add service provider to config/app.php and

Alexusmai\EasySettings\EasySettingsServiceProvider::class,

add alias.

'ESettings' => Alexusmai\EasySettings\Facades\EasySettingsFacade::class,

Publish config file (easy-settings.php)

php artisan vendor:publish --tag=easy-settings-config

You can install npm package directly and use it in your vue application - more information about it - laravel-vue-easy-settings

OR

Publish js and css files - laravel-vue-easy-settings package (compiled, minimised)

php artisan vendor:publish --tag=easy-settings-assets

Run migration -> this command create "easy-settings" table

php artisan migrate

Settings

Open configuration file - config/easy-settings.php

/**
     * List of languages
     * add the necessary ones to create additional fields(field type "Lang")
     */
    'languages'     => ['en', 'ru'],

    /**
     * Development mode
     * Show - edit/add settings group
     */
    'dev'           => true,

    /**
     * Save data to laravel cache
     * set null, 0 - if you don't need cache (default)
     * if you want use cache - set the number of minutes for which the value should be cached
     */
    'cache'         => null,

    /**
     * Middleware
     * Add your middleware name to array -> ['web', 'auth', 'admin']
     * !!!! RESTRICT ACCESS FOR NON ADMIN USERS !!!!
     */
    'middleware'    => ['web', 'auth']

In 'languages' array you can add the necessary languages

To create and edit groups of settings, you must use the developer mode. After you have added the necessary groups of settings, disable the developer mode if you do not want users to be able to change the structure, validation rules, delete, etc.

Use caching, this will avoid unnecessary queries to the database

Be sure to add your middleware to restrict access to the application

Open the view file where you want to place the application block, and add:

  • add a csrf token to head block if you did not do it before
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
  • the package uses some styles of Bootstrap 4, if you already use it, then you do not need to connect any styles. Otherwise add -
<link href="{{ asset('vendor/easy-settings/css/esettings.css') }}" rel="stylesheet">
  • add js (laravel-vue-easy-settings)
<script src="{{ asset('vendor/easy-settings/js/esettings.js') }}"></script>
  • add div for application
<div id="easy-settings-app"></div>

Usage

Now it remains to add the necessary settings groups, add fields, validation rules and can be used in your code.

ESettings::get('groupName.settingsName');
ESettings::get('groupName.settingsName', $defaultValue);
  • If you have chosen 'radios' type, the result will be a boolean type (true or false).
  • If "Lang" type is selected, the result will depend on the settings of the language of your application, at the time of the call.
  • If the desired language is not found - will be use fallback locale (see config/app.php) or default value.
'fallback_locale' => 'en',

Seeder

Sometimes you need to roll back the database while developing the project, and the package data will be lost. In order to avoid this, you can run the command

php artisan esettings:seed

That will generate a seeder (EasySettingsSeeder) that will contain your data, and you will need to add it to your seeders list (database/seeds/DatabaseSeeder.php)

统计信息

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

GitHub 信息

  • Stars: 9
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-01-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固