提交代码
This commit is contained in:
7
vendor/laravel-admin-ext/config/.gitignore
vendored
Normal file
7
vendor/laravel-admin-ext/config/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
.DS_Store
|
||||
phpunit.phar
|
||||
/vendor
|
||||
composer.phar
|
||||
composer.lock
|
||||
*.project
|
||||
.idea/
|
||||
20
vendor/laravel-admin-ext/config/LICENSE
vendored
Normal file
20
vendor/laravel-admin-ext/config/LICENSE
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Jens Segers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
60
vendor/laravel-admin-ext/config/README.md
vendored
Normal file
60
vendor/laravel-admin-ext/config/README.md
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
Config manager for laravel-admin
|
||||
========================
|
||||
|
||||
[](https://styleci.io/repos/97900916)
|
||||
[](https://packagist.org/packages/laravel-admin-ext/config)
|
||||
[](https://packagist.org/packages/laravel-admin-ext/config)
|
||||
[]()
|
||||
|
||||
Inspired by https://github.com/laravel-backpack/settings.
|
||||
|
||||
[Documentation](http://laravel-admin.org/docs/#/en/extension-config) | [中文文档](http://laravel-admin.org/docs/#/zh/extension-config)
|
||||
|
||||
## Screenshot
|
||||
|
||||

|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
$ composer require laravel-admin-ext/config
|
||||
|
||||
$ php artisan migrate
|
||||
```
|
||||
|
||||
Open `app/Providers/AppServiceProvider.php`, and call the `Config::load()` method within the `boot` method:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Encore\Admin\Config\Config;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function boot()
|
||||
{
|
||||
if (class_exists(Config::class)) {
|
||||
Config::load();
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Then run:
|
||||
|
||||
```
|
||||
$ php artisan admin:import config
|
||||
```
|
||||
|
||||
Open `http://your-host/admin/config`
|
||||
|
||||
## Usage
|
||||
|
||||
After add config in the panel, use `config($key)` to get value you configured.
|
||||
|
||||
License
|
||||
------------
|
||||
Licensed under [The MIT License (MIT)](LICENSE).
|
||||
35
vendor/laravel-admin-ext/config/composer.json
vendored
Normal file
35
vendor/laravel-admin-ext/config/composer.json
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "laravel-admin-ext/config",
|
||||
"description": "Config extension for laravel-admin",
|
||||
"type": "library",
|
||||
"keywords": ["laravel-admin", "setting"],
|
||||
"homepage": "https://github.com/laravel-admin-extensions/config",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "z-song",
|
||||
"email": "zosong@126.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.0.0",
|
||||
"laravel/framework": "~5.5",
|
||||
"encore/laravel-admin": "~1.6"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~6.0",
|
||||
"laravel/laravel": "~5.5"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Encore\\Admin\\Config\\": "src/"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Encore\\Admin\\Config\\ConfigServiceProvider"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
42
vendor/laravel-admin-ext/config/database/migrations/2017_07_17_040159_create_config_table.php
vendored
Normal file
42
vendor/laravel-admin-ext/config/database/migrations/2017_07_17_040159_create_config_table.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateConfigTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$connection = config('admin.database.connection') ?: config('database.default');
|
||||
|
||||
$table = config('admin.extensions.config.table', 'admin_config');
|
||||
|
||||
Schema::connection($connection)->create($table, function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name')->unique();
|
||||
$table->string('value');
|
||||
$table->text('description')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$connection = config('admin.database.connection') ?: config('database.default');
|
||||
|
||||
$table = config('admin.extensions.config.table', 'admin_config');
|
||||
|
||||
Schema::connection($connection)->dropIfExists($table);
|
||||
}
|
||||
}
|
||||
59
vendor/laravel-admin-ext/config/src/Config.php
vendored
Normal file
59
vendor/laravel-admin-ext/config/src/Config.php
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace Encore\Admin\Config;
|
||||
|
||||
use Encore\Admin\Admin;
|
||||
use Encore\Admin\Extension;
|
||||
|
||||
class Config extends Extension
|
||||
{
|
||||
/**
|
||||
* Load configure into laravel from database.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function load()
|
||||
{
|
||||
foreach (ConfigModel::all(['name', 'value']) as $config) {
|
||||
config([$config['name'] => $config['value']]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap this package.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function boot()
|
||||
{
|
||||
static::registerRoutes();
|
||||
|
||||
Admin::extend('config', __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register routes for laravel-admin.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function registerRoutes()
|
||||
{
|
||||
parent::routes(function ($router) {
|
||||
/* @var \Illuminate\Routing\Router $router */
|
||||
$router->resource(
|
||||
config('admin.extensions.config.name', 'config'),
|
||||
config('admin.extensions.config.controller', 'Encore\Admin\Config\ConfigController')
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function import()
|
||||
{
|
||||
parent::createMenu('Config', 'config', 'fa-toggle-on');
|
||||
|
||||
parent::createPermission('Admin Config', 'ext.config', 'config*');
|
||||
}
|
||||
}
|
||||
116
vendor/laravel-admin-ext/config/src/ConfigController.php
vendored
Normal file
116
vendor/laravel-admin-ext/config/src/ConfigController.php
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
namespace Encore\Admin\Config;
|
||||
|
||||
use Encore\Admin\Controllers\HasResourceActions;
|
||||
use Encore\Admin\Facades\Admin;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Encore\Admin\Show;
|
||||
|
||||
class ConfigController
|
||||
{
|
||||
use HasResourceActions;
|
||||
|
||||
/**
|
||||
* Index interface.
|
||||
*
|
||||
* @return Content
|
||||
*/
|
||||
public function index(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('参数配置')
|
||||
->description('list')
|
||||
->body($this->grid());
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit interface.
|
||||
*
|
||||
* @param int $id
|
||||
* @param Content $content
|
||||
*
|
||||
* @return Content
|
||||
*/
|
||||
public function edit($id, Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('Config')
|
||||
->description('edit')
|
||||
->body($this->form()->edit($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create interface.
|
||||
*
|
||||
* @param Content $content
|
||||
*
|
||||
* @return Content
|
||||
*/
|
||||
public function create(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('Config')
|
||||
->description('create')
|
||||
->body($this->form());
|
||||
}
|
||||
|
||||
public function show($id, Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('Config')
|
||||
->description('detail')
|
||||
->body(Admin::show(ConfigModel::findOrFail($id), function (Show $show) {
|
||||
$show->id();
|
||||
$show->name();
|
||||
$show->value();
|
||||
$show->description();
|
||||
$show->created_at();
|
||||
$show->updated_at();
|
||||
}));
|
||||
}
|
||||
|
||||
public function grid()
|
||||
{
|
||||
$grid = new Grid(new ConfigModel());
|
||||
|
||||
$grid->actions(function ($actions) {
|
||||
$actions->disableDelete();
|
||||
$actions->disableView();
|
||||
});
|
||||
|
||||
$grid->id('ID')->sortable();
|
||||
$grid->name('参数')->display(function ($name) {
|
||||
return "<a tabindex=\"0\" class=\"btn btn-xs btn-twitter\" role=\"button\" data-toggle=\"popover\" data-html=true title=\"Usage\" data-content=\"<code>config('$name');</code>\">$name</a>";
|
||||
});
|
||||
$grid->value('值');
|
||||
$grid->description('简介');
|
||||
|
||||
$grid->created_at('添加时间');
|
||||
$grid->updated_at('更新时间');
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->disableIdFilter();
|
||||
$filter->like('name', '参数');
|
||||
$filter->like('value', '值');
|
||||
});
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
public function form()
|
||||
{
|
||||
$form = new Form(new ConfigModel());
|
||||
|
||||
$form->display('id', 'ID');
|
||||
$form->text('name', '参数')->rules('required');
|
||||
$form->textarea('value', '值')->rules('required');
|
||||
$form->textarea('description', '简介');
|
||||
|
||||
$form->display('created_at', '添加时间');
|
||||
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
22
vendor/laravel-admin-ext/config/src/ConfigModel.php
vendored
Normal file
22
vendor/laravel-admin-ext/config/src/ConfigModel.php
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Encore\Admin\Config;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ConfigModel extends Model
|
||||
{
|
||||
/**
|
||||
* Settings constructor.
|
||||
*
|
||||
* @param array $attributes
|
||||
*/
|
||||
public function __construct($attributes = [])
|
||||
{
|
||||
parent::__construct($attributes);
|
||||
|
||||
$this->setConnection(config('admin.database.connection') ?: config('database.default'));
|
||||
|
||||
$this->setTable(config('admin.extensions.config.table', 'admin_config'));
|
||||
}
|
||||
}
|
||||
20
vendor/laravel-admin-ext/config/src/ConfigServiceProvider.php
vendored
Normal file
20
vendor/laravel-admin-ext/config/src/ConfigServiceProvider.php
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Encore\Admin\Config;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class ConfigServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
if ($this->app->runningInConsole()) {
|
||||
$this->loadMigrationsFrom(__DIR__.'/../database/migrations');
|
||||
}
|
||||
|
||||
Config::boot();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user