Browse Source

新增配置文件模块

master
崔茂正 1 year ago
parent
commit
201a240726
  1. 106
      app/Admin/Controllers/ConfigController.php
  2. 1
      app/Admin/routes.php
  3. 22
      app/Models/Config.php
  4. 20
      dcat_admin_ide_helper.php
  5. 4
      resources/lang/zh_CN/config.php

106
app/Admin/Controllers/ConfigController.php

@ -0,0 +1,106 @@ @@ -0,0 +1,106 @@
<?php
namespace App\Admin\Controllers;
use App\Models\Config;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
class ConfigController extends AdminController
{
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new Config(), function (Grid $grid) {
//开启边框模式
$grid->withBorder();
// 开启字段选择器功能
$grid->showColumnSelector();
$grid->model()->where("unique_identification", "annual_session");
$grid->column('id')->sortable();
$grid->column('data');
$grid->column('remark');
$grid->column('create_time');
$grid->column('update_time');
$grid->filter(function (Grid\Filter $filter) {
$filter->equal('id');
});
// 禁用创建按钮
$grid->disableCreateButton();
// 禁用删除按钮
$grid->disableDeleteButton();
//禁用批量操作按钮
$grid->disableBatchDelete();
// 禁用详情按钮
$grid->disableViewButton();
});
}
/**
* Make a show builder.
*
* @param mixed $id
*
* @return Show
*/
protected function detail($id)
{
return Show::make($id, new Config(), function (Show $show) {
$show->field('id');
$show->field('unique_identification');
$show->field('data');
$show->field('create_time');
$show->field('update_time');
$show->field('remark');
$show->field('created_at');
$show->field('updated_at');
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
return Form::make(new Config(), function (Form $form) {
$form->display('id');
$form->hidden('unique_identification');
$form->text('data')->required();
$form->text('remark')->required();
// 去除删除按钮
$form->disableDeleteButton();
// 去除跳转详情按钮
$form->disableViewButton();
$form->footer(function ($footer) {
// 去掉`查看`checkbox
$footer->disableViewCheck();
// 去掉`继续编辑`checkbox
$footer->disableEditingCheck();
// 去掉`继续创建`checkbox
$footer->disableCreatingCheck();
});
});
}
}

1
app/Admin/routes.php

@ -38,4 +38,5 @@ Route::group([ @@ -38,4 +38,5 @@ Route::group([
$router->resource("/wechat_app_config", "WechatAppConfigController");
$router->resource("/security_user", "SecurityUserController");
$router->resource("/loan_students_list", "LoanStudentsListController");
$router->resource("/config_list", "ConfigController");
});

22
app/Models/Config.php

@ -10,6 +10,26 @@ class Config extends Model @@ -10,6 +10,26 @@ class Config extends Model
{
use HasDateTimeFormatter;
protected $table = 'config';
public $timestamps = false;
const CREATED_AT = 'create_time';
const UPDATED_AT = 'update_time';
public $timestamps = true;
public function freshTimestamp()
{
return time();
}
/*避免转换时间戳为时间字符串*/
public function fromDateTime($value)
{
return $value;
}
protected function serializeDate(\DateTimeInterface $date)
{
return $date->format('Y-m-d H:i:s');
}
}

20
dcat_admin_ide_helper.php

@ -93,6 +93,9 @@ namespace Dcat\Admin { @@ -93,6 +93,9 @@ namespace Dcat\Admin {
* @property Grid\Column|Collection bed_number
* @property Grid\Column|Collection building_title
* @property Grid\Column|Collection teacher_id
* @property Grid\Column|Collection conllege_name
* @property Grid\Column|Collection idcard
* @property Grid\Column|Collection speciality_name
* @property Grid\Column|Collection data
* @property Grid\Column|Collection remark
* @property Grid\Column|Collection unique_identification
@ -137,7 +140,6 @@ namespace Dcat\Admin { @@ -137,7 +140,6 @@ namespace Dcat\Admin {
* @property Grid\Column|Collection dormitory_type_id
* @property Grid\Column|Collection people
* @property Grid\Column|Collection dormitory_id
* @property Grid\Column|Collection idcard
* @property Grid\Column|Collection multiple_id
* @property Grid\Column|Collection is_must
* @property Grid\Column|Collection amounts_price
@ -208,7 +210,6 @@ namespace Dcat\Admin { @@ -208,7 +210,6 @@ namespace Dcat\Admin {
* @property Grid\Column|Collection titleKey
* @property Grid\Column|Collection sms_id
* @property Grid\Column|Collection secondary_college_id
* @property Grid\Column|Collection speciality_name
* @property Grid\Column|Collection login_ip
* @property Grid\Column|Collection uid
* @property Grid\Column|Collection belongto
@ -319,6 +320,9 @@ namespace Dcat\Admin { @@ -319,6 +320,9 @@ namespace Dcat\Admin {
* @method Grid\Column|Collection bed_number(string $label = null)
* @method Grid\Column|Collection building_title(string $label = null)
* @method Grid\Column|Collection teacher_id(string $label = null)
* @method Grid\Column|Collection conllege_name(string $label = null)
* @method Grid\Column|Collection idcard(string $label = null)
* @method Grid\Column|Collection speciality_name(string $label = null)
* @method Grid\Column|Collection data(string $label = null)
* @method Grid\Column|Collection remark(string $label = null)
* @method Grid\Column|Collection unique_identification(string $label = null)
@ -363,7 +367,6 @@ namespace Dcat\Admin { @@ -363,7 +367,6 @@ namespace Dcat\Admin {
* @method Grid\Column|Collection dormitory_type_id(string $label = null)
* @method Grid\Column|Collection people(string $label = null)
* @method Grid\Column|Collection dormitory_id(string $label = null)
* @method Grid\Column|Collection idcard(string $label = null)
* @method Grid\Column|Collection multiple_id(string $label = null)
* @method Grid\Column|Collection is_must(string $label = null)
* @method Grid\Column|Collection amounts_price(string $label = null)
@ -434,7 +437,6 @@ namespace Dcat\Admin { @@ -434,7 +437,6 @@ namespace Dcat\Admin {
* @method Grid\Column|Collection titleKey(string $label = null)
* @method Grid\Column|Collection sms_id(string $label = null)
* @method Grid\Column|Collection secondary_college_id(string $label = null)
* @method Grid\Column|Collection speciality_name(string $label = null)
* @method Grid\Column|Collection login_ip(string $label = null)
* @method Grid\Column|Collection uid(string $label = null)
* @method Grid\Column|Collection belongto(string $label = null)
@ -550,6 +552,9 @@ namespace Dcat\Admin { @@ -550,6 +552,9 @@ namespace Dcat\Admin {
* @property Show\Field|Collection bed_number
* @property Show\Field|Collection building_title
* @property Show\Field|Collection teacher_id
* @property Show\Field|Collection conllege_name
* @property Show\Field|Collection idcard
* @property Show\Field|Collection speciality_name
* @property Show\Field|Collection data
* @property Show\Field|Collection remark
* @property Show\Field|Collection unique_identification
@ -594,7 +599,6 @@ namespace Dcat\Admin { @@ -594,7 +599,6 @@ namespace Dcat\Admin {
* @property Show\Field|Collection dormitory_type_id
* @property Show\Field|Collection people
* @property Show\Field|Collection dormitory_id
* @property Show\Field|Collection idcard
* @property Show\Field|Collection multiple_id
* @property Show\Field|Collection is_must
* @property Show\Field|Collection amounts_price
@ -665,7 +669,6 @@ namespace Dcat\Admin { @@ -665,7 +669,6 @@ namespace Dcat\Admin {
* @property Show\Field|Collection titleKey
* @property Show\Field|Collection sms_id
* @property Show\Field|Collection secondary_college_id
* @property Show\Field|Collection speciality_name
* @property Show\Field|Collection login_ip
* @property Show\Field|Collection uid
* @property Show\Field|Collection belongto
@ -776,6 +779,9 @@ namespace Dcat\Admin { @@ -776,6 +779,9 @@ namespace Dcat\Admin {
* @method Show\Field|Collection bed_number(string $label = null)
* @method Show\Field|Collection building_title(string $label = null)
* @method Show\Field|Collection teacher_id(string $label = null)
* @method Show\Field|Collection conllege_name(string $label = null)
* @method Show\Field|Collection idcard(string $label = null)
* @method Show\Field|Collection speciality_name(string $label = null)
* @method Show\Field|Collection data(string $label = null)
* @method Show\Field|Collection remark(string $label = null)
* @method Show\Field|Collection unique_identification(string $label = null)
@ -820,7 +826,6 @@ namespace Dcat\Admin { @@ -820,7 +826,6 @@ namespace Dcat\Admin {
* @method Show\Field|Collection dormitory_type_id(string $label = null)
* @method Show\Field|Collection people(string $label = null)
* @method Show\Field|Collection dormitory_id(string $label = null)
* @method Show\Field|Collection idcard(string $label = null)
* @method Show\Field|Collection multiple_id(string $label = null)
* @method Show\Field|Collection is_must(string $label = null)
* @method Show\Field|Collection amounts_price(string $label = null)
@ -891,7 +896,6 @@ namespace Dcat\Admin { @@ -891,7 +896,6 @@ namespace Dcat\Admin {
* @method Show\Field|Collection titleKey(string $label = null)
* @method Show\Field|Collection sms_id(string $label = null)
* @method Show\Field|Collection secondary_college_id(string $label = null)
* @method Show\Field|Collection speciality_name(string $label = null)
* @method Show\Field|Collection login_ip(string $label = null)
* @method Show\Field|Collection uid(string $label = null)
* @method Show\Field|Collection belongto(string $label = null)

4
resources/lang/zh_CN/config.php

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<?php
<?php
return [
'labels' => [
'Config' => '配置文件',
@ -6,7 +6,7 @@ return [ @@ -6,7 +6,7 @@ return [
],
'fields' => [
'unique_identification' => '标识--字段名',
'data' => '数据--值',
'data' => '数据',
'create_time' => '创建时间',
'update_time' => '修改时间',
'remark' => '备注',

Loading…
Cancel
Save