Showing
10 changed files
with
310 additions
and
27 deletions
... | @@ -85,7 +85,7 @@ class OnePoemController extends AdminController | ... | @@ -85,7 +85,7 @@ class OnePoemController extends AdminController |
85 | $form->display('id'); | 85 | $form->display('id'); |
86 | $form->text('title'); | 86 | $form->text('title'); |
87 | $form->text('author'); | 87 | $form->text('author'); |
88 | - $form->text('content'); | 88 | + $form->textarea('content'); |
89 | $form->text('annotate'); | 89 | $form->text('annotate'); |
90 | $form->text('spelling'); | 90 | $form->text('spelling'); |
91 | $form->text('en'); | 91 | $form->text('en'); | ... | ... |
... | @@ -2,7 +2,10 @@ | ... | @@ -2,7 +2,10 @@ |
2 | 2 | ||
3 | namespace App\Admin\Controllers; | 3 | namespace App\Admin\Controllers; |
4 | 4 | ||
5 | +use App\Admin\Renderable\PoemTable; | ||
6 | +use App\Admin\Renderable\TemplateTable; | ||
5 | use App\Admin\Repositories\VideoShow; | 7 | use App\Admin\Repositories\VideoShow; |
8 | +use App\Models\OnePoem; | ||
6 | use Dcat\Admin\Form; | 9 | use Dcat\Admin\Form; |
7 | use Dcat\Admin\Grid; | 10 | use Dcat\Admin\Grid; |
8 | use Dcat\Admin\Show; | 11 | use Dcat\Admin\Show; |
... | @@ -62,11 +65,60 @@ class VideoShowController extends AdminController | ... | @@ -62,11 +65,60 @@ class VideoShowController extends AdminController |
62 | { | 65 | { |
63 | return Form::make(new VideoShow(), function (Form $form) { | 66 | return Form::make(new VideoShow(), function (Form $form) { |
64 | $form->display('id'); | 67 | $form->display('id'); |
65 | - $form->text('video_url'); | 68 | + |
66 | - $form->text('video_size'); | 69 | + $form->selectTable('poem_id','选择一言') |
67 | - $form->text('video_time'); | 70 | + ->title('一言诗词库') |
68 | - $form->text('is_horizontal'); | 71 | + ->from(PoemTable::make()); |
69 | - | 72 | + |
73 | +// $form->radio('type')->addElementClass('type') | ||
74 | +// ->options([1=>'图文音频',2=>'视频'])->default(1); | ||
75 | + | ||
76 | + $form->radio('type') | ||
77 | + ->options([1=>'视频', 2=>'图文音频']) | ||
78 | + ->when(1,function (Form $form){ | ||
79 | + $form->file('bg_url','上传视频') | ||
80 | + ->accept('mp4') | ||
81 | + ->autoUpload() | ||
82 | + ->uniqueName() | ||
83 | + ->addElementClass('bg_video_url'); | ||
84 | + }) | ||
85 | + ->when(2,function (Form $form){ | ||
86 | + $form->multipleImage('bg_url','上传图片') | ||
87 | + ->limit(5) | ||
88 | + ->uniqueName() | ||
89 | + ->addElementClass('bg_img_url'); | ||
90 | + }) | ||
91 | + ->default(1); | ||
92 | + $form->radio('bg_music','背景音') | ||
93 | + ->options(['无', '有']) | ||
94 | + ->when(1,function (Form $form){ | ||
95 | + $form->file('bgm_url','上传背景音') | ||
96 | + ->accept('mp3,aac,wav') | ||
97 | + ->autoUpload() | ||
98 | + ->uniqueName() | ||
99 | + ->addElementClass('bgm_url'); | ||
100 | + }) | ||
101 | + ->default(0); | ||
102 | + | ||
103 | + $form->textarea('feel','有感'); | ||
104 | + | ||
105 | + $form->selectTable('poem_id','选择模板') | ||
106 | + ->title('模板选择') | ||
107 | + ->from(TemplateTable::make()); | ||
108 | + | ||
109 | + $form->radio('thumbnail','封面') | ||
110 | + ->options([1=>'手动上传', 2=>'选择截屏']) | ||
111 | + ->when(1,function (Form $form){ | ||
112 | + $form->multipleImage('bg_url','上传图片') | ||
113 | + ->limit(5) | ||
114 | + ->uniqueName() | ||
115 | + ->addElementClass('bg_img_url'); | ||
116 | + }) | ||
117 | + ->when(2,function (Form $form){ | ||
118 | + $form->html(''); | ||
119 | + }) | ||
120 | + ->default(1); | ||
121 | + | ||
70 | $form->display('created_at'); | 122 | $form->display('created_at'); |
71 | $form->display('updated_at'); | 123 | $form->display('updated_at'); |
72 | }); | 124 | }); | ... | ... |
... | @@ -2,16 +2,18 @@ | ... | @@ -2,16 +2,18 @@ |
2 | 2 | ||
3 | namespace App\Admin\Controllers; | 3 | namespace App\Admin\Controllers; |
4 | 4 | ||
5 | -use App\Admin\Repositories\VideoTemp; | 5 | +use App\Models\VideoTemp; |
6 | +use App\Models\Component; | ||
6 | use Dcat\Admin\Form; | 7 | use Dcat\Admin\Form; |
7 | use Dcat\Admin\Grid; | 8 | use Dcat\Admin\Grid; |
8 | use Dcat\Admin\Show; | 9 | use Dcat\Admin\Show; |
9 | use Dcat\Admin\Http\Controllers\AdminController; | 10 | use Dcat\Admin\Http\Controllers\AdminController; |
10 | -use Illuminate\Http\Request; | 11 | +use Dcat\Admin\Widgets\Table; |
12 | +use Illuminate\Support\Facades\DB; | ||
11 | 13 | ||
12 | class VideoTempController extends AdminController | 14 | class VideoTempController extends AdminController |
13 | { | 15 | { |
14 | - protected $title = '视频模板'; | 16 | + protected $title = '临境模板'; |
15 | /** | 17 | /** |
16 | * Make a grid builder. | 18 | * Make a grid builder. |
17 | * | 19 | * |
... | @@ -20,20 +22,28 @@ class VideoTempController extends AdminController | ... | @@ -20,20 +22,28 @@ class VideoTempController extends AdminController |
20 | protected function grid() | 22 | protected function grid() |
21 | { | 23 | { |
22 | return Grid::make(new VideoTemp(), function (Grid $grid) { | 24 | return Grid::make(new VideoTemp(), function (Grid $grid) { |
25 | + $grid->model()->with('components'); | ||
26 | + | ||
23 | // 设置自定义视图 | 27 | // 设置自定义视图 |
24 | $grid->setActionClass(Grid\Displayers\Actions::class); | 28 | $grid->setActionClass(Grid\Displayers\Actions::class); |
25 | 29 | ||
26 | $grid->column('id',__('ID'))->sortable(); | 30 | $grid->column('id',__('ID'))->sortable(); |
27 | $grid->column('title'); | 31 | $grid->column('title'); |
28 | - $grid->column('type'); | 32 | + $grid->column('','组件信息') |
29 | - $grid->column('bg_type'); | 33 | + ->display('展开') |
30 | - $grid->column('bg_url')->image('/storage/'); | 34 | + ->expand(function (){ |
31 | - $grid->column('bg_music'); | 35 | + $th = ['id','模板id','名称','位置','字号','字体颜色','背景色','透明度','创建时间','修改时间']; |
32 | - $grid->column('state'); | 36 | + return Table::make($th, $this->components->toArray())->withBorder(); |
33 | - $grid->column('sn'); | 37 | + }); |
34 | - $grid->column('top'); | 38 | +// $grid->column('type'); |
35 | - $grid->column('left'); | 39 | +// $grid->column('bg_type'); |
36 | - $grid->column('font_size'); | 40 | +// $grid->column('bg_url')->image('/storage/'); |
41 | +// $grid->column('bg_music'); | ||
42 | + $grid->column('state')->switch(); | ||
43 | +// $grid->column('sn'); | ||
44 | +// $grid->column('top'); | ||
45 | +// $grid->column('left'); | ||
46 | +// $grid->column('font_size'); | ||
37 | $grid->column('created_at'); | 47 | $grid->column('created_at'); |
38 | $grid->column('updated_at')->sortable(); | 48 | $grid->column('updated_at')->sortable(); |
39 | // | 49 | // |
... | @@ -75,7 +85,7 @@ class VideoTempController extends AdminController | ... | @@ -75,7 +85,7 @@ class VideoTempController extends AdminController |
75 | * | 85 | * |
76 | * @return Form | 86 | * @return Form |
77 | */ | 87 | */ |
78 | - protected function form() | 88 | + protected function form2() |
79 | { | 89 | { |
80 | return Form::make(new VideoTemp(), function (Form $form) { | 90 | return Form::make(new VideoTemp(), function (Form $form) { |
81 | $form->display('id'); | 91 | $form->display('id'); |
... | @@ -139,4 +149,107 @@ class VideoTempController extends AdminController | ... | @@ -139,4 +149,107 @@ class VideoTempController extends AdminController |
139 | $form->display('updated_at'); | 149 | $form->display('updated_at'); |
140 | }); | 150 | }); |
141 | } | 151 | } |
152 | + | ||
153 | + /** | ||
154 | + * Make a form builder. | ||
155 | + * | ||
156 | + * @return Form | ||
157 | + */ | ||
158 | + protected function form() | ||
159 | + { | ||
160 | + return Form::make(new VideoTemp(), function (Form $form) { | ||
161 | + $form->display('id'); | ||
162 | + $form->block(8, function (Form\BlockForm $form) { | ||
163 | + // 设置标题 | ||
164 | + $form->title('基本设置'); | ||
165 | + // 显示底部提交按钮 | ||
166 | + $form->showFooter(); | ||
167 | + // 设置字段宽度 | ||
168 | + $form->width(8, 3); | ||
169 | + | ||
170 | + $form->text('title'); | ||
171 | + | ||
172 | + $form->checkbox('components','组件') | ||
173 | + ->when('every_poem', function (Form\BlockForm $form) { | ||
174 | + $form->select('pos_every_poem', '每日位置')->options([ | ||
175 | + 'topLeft'=>'上左','topMiddle'=>'上中','topRight'=>'上右', | ||
176 | + ]); | ||
177 | + $form->divider(); | ||
178 | + }) | ||
179 | + ->when('one_poem', function (Form\BlockForm $form) { | ||
180 | + $form->select('pos_one_poem', '一言位置')->options([ | ||
181 | + 'topLeft'=>'上左','topMiddle'=>'上中','topRight'=>'上右', | ||
182 | + ]); | ||
183 | + $form->divider(); | ||
184 | + }) | ||
185 | + ->when('weather', function (Form\BlockForm $form) { | ||
186 | + $form->select('pos_weather', '天气位置')->options([ | ||
187 | + 'topLeft'=>'上左','topMiddle'=>'上中','topRight'=>'上右', | ||
188 | + ]); | ||
189 | + $form->divider(); | ||
190 | + }) | ||
191 | + ->when('date', function (Form\BlockForm $form) { | ||
192 | + $form->select('pos_date', '日期位置')->options([ | ||
193 | + 'topLeft'=>'上左','topMiddle'=>'上中','topRight'=>'上右', | ||
194 | + ]); | ||
195 | + $form->divider(); | ||
196 | + }) | ||
197 | + ->when('feel', function (Form\BlockForm $form) { | ||
198 | + $form->select('pos_feel', '日期位置')->options([ | ||
199 | + 'topLeft'=>'上左','topMiddle'=>'上中','topRight'=>'上右', | ||
200 | + ]); | ||
201 | + $form->divider(); | ||
202 | + }) | ||
203 | + ->default(['one_poem','weather','date']) | ||
204 | + ->options([ | ||
205 | + 'every_poem' => '每日一言组件', | ||
206 | + 'one_poem' => '一言组件', | ||
207 | + 'weather' => '天气组件', | ||
208 | + 'date' => '日期组件', | ||
209 | + 'feel' => '临境有感组件', | ||
210 | + ]); | ||
211 | + | ||
212 | + | ||
213 | + $form->hidden('state') | ||
214 | + ->saving(function ($v) { | ||
215 | + return $v; | ||
216 | + }); | ||
217 | + }); | ||
218 | + | ||
219 | +// $form->block(4, function (Form\BlockForm $form) { | ||
220 | +// $form->html(view('admin.form.phone')); | ||
221 | +// }); | ||
222 | + | ||
223 | + $form->display('created_at'); | ||
224 | + $form->display('updated_at'); | ||
225 | + }); | ||
226 | + } | ||
227 | + | ||
228 | + public function store() | ||
229 | + { | ||
230 | + $all = \request()->all(); | ||
231 | + dd($all); | ||
232 | + try{ | ||
233 | + DB::transaction(function ()use ($all){ | ||
234 | + $vide_temp = VideoTemp::query()->create([ | ||
235 | + 'title' => $all['title'], | ||
236 | + 'state' => 1, | ||
237 | + ]); | ||
238 | + foreach ($all['components'] as $component) { | ||
239 | + if ($component !== null){ | ||
240 | + Component::query()->create([ | ||
241 | + 'temp_id' => $vide_temp->id, | ||
242 | + 'name' => $component, | ||
243 | + 'position' => $all['pos_' . $component] | ||
244 | + ]); | ||
245 | + } | ||
246 | + } | ||
247 | + }); | ||
248 | + | ||
249 | + }catch (\Exception $exception){ | ||
250 | + return $this->form()->response()->error($exception->getMessage()); | ||
251 | + } | ||
252 | + | ||
253 | + return $this->form()->response()->refresh()->success(trans('admin.save_succeeded')); | ||
254 | + } | ||
142 | } | 255 | } | ... | ... |
... | @@ -22,8 +22,8 @@ class PoemTable extends LazyRenderable | ... | @@ -22,8 +22,8 @@ class PoemTable extends LazyRenderable |
22 | $grid->column('author'); | 22 | $grid->column('author'); |
23 | $grid->column('content'); | 23 | $grid->column('content'); |
24 | $grid->column('annotate'); | 24 | $grid->column('annotate'); |
25 | - $grid->column('spelling'); | 25 | +// $grid->column('spelling'); |
26 | - $grid->column('en'); | 26 | +// $grid->column('en'); |
27 | 27 | ||
28 | $grid->quickSearch(['title', 'author', 'content', 'annotate']); | 28 | $grid->quickSearch(['title', 'author', 'content', 'annotate']); |
29 | 29 | ||
... | @@ -31,8 +31,9 @@ class PoemTable extends LazyRenderable | ... | @@ -31,8 +31,9 @@ class PoemTable extends LazyRenderable |
31 | $grid->disableActions(); | 31 | $grid->disableActions(); |
32 | 32 | ||
33 | $grid->filter(function (Grid\Filter $filter) { | 33 | $grid->filter(function (Grid\Filter $filter) { |
34 | - $filter->like('username')->width(4); | 34 | + $filter->like('title')->width(3); |
35 | - $filter->like('name')->width(4); | 35 | + $filter->like('author')->width(3); |
36 | + $filter->like('content')->width(3); | ||
36 | }); | 37 | }); |
37 | }); | 38 | }); |
38 | } | 39 | } | ... | ... |
app/Admin/Renderable/TemplateTable.php
0 → 100644
1 | +<?php | ||
2 | +/** | ||
3 | + * Created by PhpStorm. | ||
4 | + * User: lishuai | ||
5 | + * Date: 2022/1/10 | ||
6 | + * Time: 5:57 PM | ||
7 | + */ | ||
8 | + | ||
9 | +namespace App\Admin\Renderable; | ||
10 | + | ||
11 | +use App\Models\VideoTemp; | ||
12 | +use Dcat\Admin\Grid; | ||
13 | +use Dcat\Admin\Grid\LazyRenderable; | ||
14 | +use Dcat\Admin\Widgets\Table; | ||
15 | + | ||
16 | +class TemplateTable extends LazyRenderable | ||
17 | +{ | ||
18 | + public function grid(): Grid | ||
19 | + { | ||
20 | + return Grid::make(new VideoTemp(), function (Grid $grid) { | ||
21 | + $grid->model()->with(['componentsTable']); | ||
22 | + $grid->column('id', 'ID')->sortable(); | ||
23 | + $grid->column('title'); | ||
24 | + $grid->column('','组件信息') | ||
25 | + ->display('展开') | ||
26 | + ->expand(function (){ | ||
27 | + $th = ['id','模板id','名称','位置','字号']; | ||
28 | + return Table::make($th, $this->componentsTable->toArray())->withBorder(); | ||
29 | + }); | ||
30 | + | ||
31 | + $grid->column('state')->switch(); | ||
32 | + $grid->quickSearch(['title']); | ||
33 | + | ||
34 | + $grid->paginate(10); | ||
35 | + $grid->disableActions(); | ||
36 | + | ||
37 | + $grid->filter(function (Grid\Filter $filter) { | ||
38 | + $filter->like('title')->width(3); | ||
39 | + $filter->like('author')->width(3); | ||
40 | + $filter->like('content')->width(3); | ||
41 | + }); | ||
42 | + }); | ||
43 | + } | ||
44 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -24,8 +24,11 @@ Route::group([ | ... | @@ -24,8 +24,11 @@ Route::group([ |
24 | /** 众妙*/ | 24 | /** 众妙*/ |
25 | $router->resource('/package', 'PackPoemController'); | 25 | $router->resource('/package', 'PackPoemController'); |
26 | 26 | ||
27 | - /** 视频模板*/ | 27 | + /** 临境*/ |
28 | - $router->resource('/template', 'VideoTempController'); | 28 | + $router->group(['prefix'=>'/linjing'],function (Router $router){ |
29 | + $router->resource('/template', 'VideoTempController'); | ||
30 | + $router->resource('/official', 'VideoShowController'); | ||
31 | + }); | ||
29 | 32 | ||
30 | /** 订单*/ | 33 | /** 订单*/ |
31 | $router->resource('/order', 'OrderController'); | 34 | $router->resource('/order', 'OrderController'); | ... | ... |
app/Models/Component.php
0 → 100644
... | @@ -10,5 +10,16 @@ class VideoTemp extends Model | ... | @@ -10,5 +10,16 @@ class VideoTemp extends Model |
10 | { | 10 | { |
11 | use HasDateTimeFormatter; | 11 | use HasDateTimeFormatter; |
12 | protected $table = 'video_temp'; | 12 | protected $table = 'video_temp'; |
13 | - | 13 | + |
14 | + protected $guarded = ['']; | ||
15 | + | ||
16 | + public function components() | ||
17 | + { | ||
18 | + return $this->hasMany('App\Models\Component','temp_id'); | ||
19 | + } | ||
20 | + | ||
21 | + public function componentsTable() | ||
22 | + { | ||
23 | + return $this->hasMany('App\Models\Component','temp_id')->select(['id','temp_id','name','position','font_size']); | ||
24 | + } | ||
14 | } | 25 | } | ... | ... |
1 | +<?php | ||
2 | + | ||
3 | +use Illuminate\Database\Migrations\Migration; | ||
4 | +use Illuminate\Database\Schema\Blueprint; | ||
5 | +use Illuminate\Support\Facades\Schema; | ||
6 | + | ||
7 | +class CreateComponentsTable extends Migration | ||
8 | +{ | ||
9 | + /** | ||
10 | + * Run the migrations. | ||
11 | + * | ||
12 | + * @return void | ||
13 | + */ | ||
14 | + public function up() | ||
15 | + { | ||
16 | + Schema::dropIfExists('video_temp'); | ||
17 | + | ||
18 | + Schema::create('video_temp', function (Blueprint $table) { | ||
19 | + $table->id(); | ||
20 | + $table->string('title'); | ||
21 | + $table->unsignedTinyInteger('state'); | ||
22 | + $table->timestamps(); | ||
23 | + }); | ||
24 | + | ||
25 | + Schema::create('components', function (Blueprint $table) { | ||
26 | + $table->id(); | ||
27 | + $table->unsignedInteger('temp_id'); | ||
28 | + $table->string('name')->comment('组件名称'); | ||
29 | + $table->string('position')->nullable()->comment('位置'); | ||
30 | + $table->unsignedTinyInteger('font_size')->default(12)->comment('字号'); | ||
31 | + $table->string('text_color')->nullable()->comment('文字颜色'); | ||
32 | + $table->string('text_bg_color')->nullable()->comment('文字背景色'); | ||
33 | + $table->double('opacity')->nullable()->comment('透明度'); | ||
34 | + $table->timestamps(); | ||
35 | + }); | ||
36 | + } | ||
37 | + | ||
38 | + /** | ||
39 | + * Reverse the migrations. | ||
40 | + * | ||
41 | + * @return void | ||
42 | + */ | ||
43 | + public function down() | ||
44 | + { | ||
45 | + Schema::dropIfExists('components'); | ||
46 | + } | ||
47 | +} |
... | @@ -15,7 +15,6 @@ use Illuminate\Routing\Router; | ... | @@ -15,7 +15,6 @@ use Illuminate\Routing\Router; |
15 | */ | 15 | */ |
16 | 16 | ||
17 | Route::prefix('v1')->namespace('App\Http\Controllers\V1')->group(function (Router $api){ | 17 | Route::prefix('v1')->namespace('App\Http\Controllers\V1')->group(function (Router $api){ |
18 | - | ||
19 | /** 移动端微信用户登录*/ | 18 | /** 移动端微信用户登录*/ |
20 | $api->get('login/{service}/callback', 'AuthController@apiHandleProviderCallback'); | 19 | $api->get('login/{service}/callback', 'AuthController@apiHandleProviderCallback'); |
21 | }); | 20 | }); | ... | ... |
-
Please register or login to post a comment