1
0

提交代码

This commit is contained in:
2020-08-06 14:50:07 +08:00
parent 9d0d5f4be9
commit d7a848c824
11299 changed files with 1321854 additions and 0 deletions

View 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
View 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.

View File

@@ -0,0 +1,60 @@
Config manager for laravel-admin
========================
[![StyleCI](https://styleci.io/repos/97900916/shield?branch=master)](https://styleci.io/repos/97900916)
[![Packagist](https://img.shields.io/packagist/l/laravel-admin-ext/config.svg?maxAge=2592000)](https://packagist.org/packages/laravel-admin-ext/config)
[![Total Downloads](https://img.shields.io/packagist/dt/laravel-admin-ext/config.svg?style=flat-square)](https://packagist.org/packages/laravel-admin-ext/config)
[![Pull request welcome](https://img.shields.io/badge/pr-welcome-green.svg?style=flat-square)]()
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
![wx20170810-100226](https://user-images.githubusercontent.com/1479100/29151322-0879681a-7db3-11e7-8005-03310686c884.png)
## 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).

View 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"
]
}
}
}

View 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);
}
}

View 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*');
}
}

View 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;
}
}

View 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'));
}
}

View 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();
}
}