VideoTempController.php
4.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
namespace App\Admin\Controllers;
use App\Admin\Repositories\VideoTemp;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
class VideoTempController extends AdminController
{
protected $title = '视频模板';
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new VideoTemp(), function (Grid $grid) {
// 设置自定义视图
$grid->view('admin.grid.custom');
$grid->setActionClass(Grid\Displayers\Actions::class);
// $grid->column('id',__('ID'))->sortable();
// $grid->column('title');
// $grid->column('type');
// $grid->column('bg_type');
// $grid->column('bg_url');
// $grid->column('bg_music');
// $grid->column('state');
// $grid->column('sn');
// $grid->column('top');
// $grid->column('left');
// $grid->column('font_size');
// $grid->column('created_at');
// $grid->column('updated_at')->sortable();
//
// $grid->filter(function (Grid\Filter $filter) {
// $filter->equal('id');
//
// });
});
}
/**
* Make a show builder.
*
* @param mixed $id
*
* @return Show
*/
protected function detail($id)
{
return Show::make($id, new VideoTemp(), function (Show $show) {
$show->field('id');
$show->field('title');
$show->field('type');
$show->field('bg_type');
$show->field('bg_url');
$show->field('bg_music');
$show->field('state');
$show->field('sn');
$show->field('top');
$show->field('left');
$show->field('font_size');
$show->field('created_at');
$show->field('updated_at');
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
return Form::make(new VideoTemp(), function (Form $form) {
$form->display('id');
$form->block(8, function (Form\BlockForm $form) {
// 设置标题
$form->title('基本设置');
// 显示底部提交按钮
$form->showFooter();
// 设置字段宽度
$form->width(8, 3);
$form->column(12, function (Form\BlockForm $form) {
$form->text('title');
$form->radio('type')->options(['视频', '图文音频'])->default(0);
$form->radio('bg_type')
->options([1=>'视频', 2=>'图片'])
->when(1,function (Form\BlockForm $form){
$form->file('bg_url')
->accept('mp4')
->autoUpload()
->uniqueName()
->addElementClass('bg_url');
})
->when(2,function (Form\BlockForm $form){
$form->multipleImage('bg_url')
->limit(5)
->uniqueName()
->addElementClass('multi_bg_url');
})
->default(1);
$form->radio('bg_music')
->options(['无', '有'])
->when(1,function (Form\BlockForm $form){
$form->text('bgm_url');
})
->default(0);
$form->number('top');
$form->number('left');
$form->number('font_size');
$form->number('sn');
$form->radio('state')->options(['不显示', '显示'])->default(0);
});
});
$form->block(4, function (Form\BlockForm $form) {
$form->html(view('admin.form.phone'));
});
$form->display('created_at');
$form->display('updated_at');
});
}
}