Showing
12 changed files
with
284 additions
and
34 deletions
1 | +<?php | ||
2 | + | ||
3 | +namespace App\Admin\Controllers; | ||
4 | + | ||
5 | +use App\Admin\Renderable\PoemTable; | ||
6 | +use App\Admin\Renderable\TemplateTable; | ||
7 | +use App\Jobs\MakeVideo; | ||
8 | +use App\Models\AdminMakeVideo; | ||
9 | +use App\Models\Order; | ||
10 | +use Dcat\Admin\Form; | ||
11 | +use Dcat\Admin\Grid; | ||
12 | +use Dcat\Admin\Layout\Content; | ||
13 | +use Dcat\Admin\Show; | ||
14 | +use Dcat\Admin\Http\Controllers\AdminController; | ||
15 | + | ||
16 | +class AdminMakeVideoController extends AdminController | ||
17 | +{ | ||
18 | + /** | ||
19 | + * Make a grid builder. | ||
20 | + * | ||
21 | + * @return Grid | ||
22 | + */ | ||
23 | + protected function grid() | ||
24 | + { | ||
25 | + return Grid::make(new AdminMakeVideo(), function (Grid $grid) { | ||
26 | + $grid->column('id')->sortable(); | ||
27 | + $grid->column('poem_id'); | ||
28 | + $grid->column('type'); | ||
29 | + $grid->column('video_url'); | ||
30 | + $grid->column('images_url'); | ||
31 | + $grid->column('bg_music'); | ||
32 | + $grid->column('bgm_url'); | ||
33 | + $grid->column('feel'); | ||
34 | + $grid->column('temp_id'); | ||
35 | + $grid->column('thumbnail'); | ||
36 | + $grid->column('thumbnail_url'); | ||
37 | + $grid->column('created_at'); | ||
38 | + $grid->column('updated_at')->sortable(); | ||
39 | + | ||
40 | + $grid->filter(function (Grid\Filter $filter) { | ||
41 | + $filter->equal('id'); | ||
42 | + | ||
43 | + }); | ||
44 | + }); | ||
45 | + } | ||
46 | + | ||
47 | + /** | ||
48 | + * Make a show builder. | ||
49 | + * | ||
50 | + * @param mixed $id | ||
51 | + * | ||
52 | + * @return Show | ||
53 | + */ | ||
54 | + protected function detail($id) | ||
55 | + { | ||
56 | + return Show::make($id, new AdminMakeVideo(), function (Show $show) { | ||
57 | + $show->field('id'); | ||
58 | + $show->field('poem_id'); | ||
59 | + $show->field('type'); | ||
60 | + $show->field('video_url'); | ||
61 | + $show->field('images_url'); | ||
62 | + $show->field('bg_music'); | ||
63 | + $show->field('bgm_url'); | ||
64 | + $show->field('feel'); | ||
65 | + $show->field('temp_id'); | ||
66 | + $show->field('thumbnail'); | ||
67 | + $show->field('thumbnail_url'); | ||
68 | + $show->field('created_at'); | ||
69 | + $show->field('updated_at'); | ||
70 | + }); | ||
71 | + } | ||
72 | + | ||
73 | + /** | ||
74 | + * Make a form builder. | ||
75 | + * | ||
76 | + * @return Form | ||
77 | + */ | ||
78 | + protected function form() | ||
79 | + { | ||
80 | + return Form::make(new AdminMakeVideo(), function (Form $form) { | ||
81 | + $form->display('id'); | ||
82 | + | ||
83 | + $form->selectTable('poem_id','选择一言') | ||
84 | + ->title('一言诗词库') | ||
85 | + ->from(PoemTable::make()); | ||
86 | + | ||
87 | + $form->radio('type') | ||
88 | + ->options([1=>'视频', 2=>'图文音频']) | ||
89 | + ->when(1,function (Form $form){ | ||
90 | + $form->file('video_url','上传视频') | ||
91 | + ->accept('mp4') | ||
92 | + ->autoUpload() | ||
93 | + ->uniqueName() | ||
94 | + ->maxSize('102400') | ||
95 | + ->addElementClass('video_url'); | ||
96 | + }) | ||
97 | + ->when(2,function (Form $form){ | ||
98 | + $form->multipleImage('images_url','上传图片') | ||
99 | + ->limit(5) | ||
100 | + ->uniqueName() | ||
101 | + ->addElementClass('images_url'); | ||
102 | + }) | ||
103 | + ->default(1); | ||
104 | + $form->radio('bg_music','背景音') | ||
105 | + ->options(['无', '有']) | ||
106 | + ->when(1,function (Form $form){ | ||
107 | + $form->file('bgm_url','上传背景音') | ||
108 | + ->accept('mp3,aac,wav') | ||
109 | + ->autoUpload() | ||
110 | + ->uniqueName() | ||
111 | + ->addElementClass('bg_music'); | ||
112 | + }) | ||
113 | + ->default(0); | ||
114 | + | ||
115 | + $form->textarea('feel','有感'); | ||
116 | + | ||
117 | + $form->selectTable('temp_id','选择模板') | ||
118 | + ->title('模板选择') | ||
119 | + ->from(TemplateTable::make()); | ||
120 | + | ||
121 | + $form->radio('thumbnail','封面') | ||
122 | + ->options([1=>'手动上传', 2=>'自动截屏']) | ||
123 | + ->when(1,function (Form $form){ | ||
124 | + $form->multipleImage('thumbnail_url','上传图片') | ||
125 | + ->limit(5) | ||
126 | + ->uniqueName(); | ||
127 | +// ->addElementClass('bg_img_url'); | ||
128 | + }) | ||
129 | + ->when(2,function (Form $form){ | ||
130 | + $form->html(''); | ||
131 | + }) | ||
132 | + ->default(1); | ||
133 | + | ||
134 | + $form->display('created_at'); | ||
135 | + $form->display('updated_at'); | ||
136 | + }); | ||
137 | + } | ||
138 | + | ||
139 | + public function store() | ||
140 | + { | ||
141 | + $all = request()->all(); | ||
142 | + | ||
143 | + if (isset($all['upload_column'])) return $this->form()->store(); | ||
144 | + | ||
145 | + try{ | ||
146 | + $video = AdminMakeVideo::query()->create($all); | ||
147 | + // 添加至队列 | ||
148 | + MakeVideo::dispatch($video); | ||
149 | + | ||
150 | + }catch (\Exception $exception){ | ||
151 | + return $this->form()->response()->error($exception->getMessage()); | ||
152 | + } | ||
153 | + | ||
154 | + return $this->form()->response()->refresh()->success(trans('admin.save_succeeded')); | ||
155 | + } | ||
156 | +} |
... | @@ -5,7 +5,7 @@ namespace App\Admin\Controllers; | ... | @@ -5,7 +5,7 @@ namespace App\Admin\Controllers; |
5 | use App\Admin\Renderable\PoemTable; | 5 | use App\Admin\Renderable\PoemTable; |
6 | use App\Admin\Renderable\TemplateTable; | 6 | use App\Admin\Renderable\TemplateTable; |
7 | use App\Admin\Repositories\VideoShow; | 7 | use App\Admin\Repositories\VideoShow; |
8 | -use App\Models\OnePoem; | 8 | +use App\Models\AdminMakeVideo; |
9 | use Dcat\Admin\Form; | 9 | use Dcat\Admin\Form; |
10 | use Dcat\Admin\Grid; | 10 | use Dcat\Admin\Grid; |
11 | use Dcat\Admin\Show; | 11 | use Dcat\Admin\Show; |
... | @@ -63,30 +63,28 @@ class VideoShowController extends AdminController | ... | @@ -63,30 +63,28 @@ class VideoShowController extends AdminController |
63 | */ | 63 | */ |
64 | protected function form() | 64 | protected function form() |
65 | { | 65 | { |
66 | - return Form::make(new VideoShow(), function (Form $form) { | 66 | + return Form::make(new AdminMakeVideo(), function (Form $form) { |
67 | $form->display('id'); | 67 | $form->display('id'); |
68 | 68 | ||
69 | $form->selectTable('poem_id','选择一言') | 69 | $form->selectTable('poem_id','选择一言') |
70 | ->title('一言诗词库') | 70 | ->title('一言诗词库') |
71 | ->from(PoemTable::make()); | 71 | ->from(PoemTable::make()); |
72 | 72 | ||
73 | -// $form->radio('type')->addElementClass('type') | ||
74 | -// ->options([1=>'图文音频',2=>'视频'])->default(1); | ||
75 | - | ||
76 | $form->radio('type') | 73 | $form->radio('type') |
77 | ->options([1=>'视频', 2=>'图文音频']) | 74 | ->options([1=>'视频', 2=>'图文音频']) |
78 | ->when(1,function (Form $form){ | 75 | ->when(1,function (Form $form){ |
79 | - $form->file('bg_url','上传视频') | 76 | + $form->file('video_url','上传视频') |
80 | ->accept('mp4') | 77 | ->accept('mp4') |
81 | ->autoUpload() | 78 | ->autoUpload() |
82 | ->uniqueName() | 79 | ->uniqueName() |
83 | - ->addElementClass('bg_video_url'); | 80 | + ->maxSize('102400') |
81 | + ->addElementClass('video_url'); | ||
84 | }) | 82 | }) |
85 | ->when(2,function (Form $form){ | 83 | ->when(2,function (Form $form){ |
86 | - $form->multipleImage('bg_url','上传图片') | 84 | + $form->multipleImage('images_url','上传图片') |
87 | ->limit(5) | 85 | ->limit(5) |
88 | ->uniqueName() | 86 | ->uniqueName() |
89 | - ->addElementClass('bg_img_url'); | 87 | + ->addElementClass('images_url'); |
90 | }) | 88 | }) |
91 | ->default(1); | 89 | ->default(1); |
92 | $form->radio('bg_music','背景音') | 90 | $form->radio('bg_music','背景音') |
... | @@ -96,23 +94,23 @@ class VideoShowController extends AdminController | ... | @@ -96,23 +94,23 @@ class VideoShowController extends AdminController |
96 | ->accept('mp3,aac,wav') | 94 | ->accept('mp3,aac,wav') |
97 | ->autoUpload() | 95 | ->autoUpload() |
98 | ->uniqueName() | 96 | ->uniqueName() |
99 | - ->addElementClass('bgm_url'); | 97 | + ->addElementClass('bg_music'); |
100 | }) | 98 | }) |
101 | ->default(0); | 99 | ->default(0); |
102 | 100 | ||
103 | $form->textarea('feel','有感'); | 101 | $form->textarea('feel','有感'); |
104 | 102 | ||
105 | - $form->selectTable('poem_id','选择模板') | 103 | + $form->selectTable('temp_id','选择模板') |
106 | ->title('模板选择') | 104 | ->title('模板选择') |
107 | ->from(TemplateTable::make()); | 105 | ->from(TemplateTable::make()); |
108 | 106 | ||
109 | $form->radio('thumbnail','封面') | 107 | $form->radio('thumbnail','封面') |
110 | - ->options([1=>'手动上传', 2=>'选择截屏']) | 108 | + ->options([1=>'手动上传', 2=>'自动截屏']) |
111 | ->when(1,function (Form $form){ | 109 | ->when(1,function (Form $form){ |
112 | - $form->multipleImage('bg_url','上传图片') | 110 | + $form->multipleImage('thumbnail_url','上传图片') |
113 | ->limit(5) | 111 | ->limit(5) |
114 | - ->uniqueName() | 112 | + ->uniqueName(); |
115 | - ->addElementClass('bg_img_url'); | 113 | +// ->addElementClass('bg_img_url'); |
116 | }) | 114 | }) |
117 | ->when(2,function (Form $form){ | 115 | ->when(2,function (Form $form){ |
118 | $form->html(''); | 116 | $form->html(''); |
... | @@ -123,4 +121,22 @@ class VideoShowController extends AdminController | ... | @@ -123,4 +121,22 @@ class VideoShowController extends AdminController |
123 | $form->display('updated_at'); | 121 | $form->display('updated_at'); |
124 | }); | 122 | }); |
125 | } | 123 | } |
124 | + | ||
125 | + public function store() | ||
126 | + { | ||
127 | + $all = request()->all(); | ||
128 | + | ||
129 | + if (isset($all['upload_column'])) return $this->form()->store(); | ||
130 | + | ||
131 | + try{ | ||
132 | + $video = AdminMakeVideo::query()->create($all); | ||
133 | + | ||
134 | + // todo 添加至队列 | ||
135 | + | ||
136 | + }catch (\Exception $exception){ | ||
137 | + return $this->form()->response()->error($exception->getMessage()); | ||
138 | + } | ||
139 | + | ||
140 | + return $this->form()->response()->refresh()->success(trans('admin.save_succeeded')); | ||
141 | + } | ||
126 | } | 142 | } | ... | ... |
... | @@ -171,33 +171,23 @@ class VideoTempController extends AdminController | ... | @@ -171,33 +171,23 @@ class VideoTempController extends AdminController |
171 | 171 | ||
172 | $form->checkbox('components','组件') | 172 | $form->checkbox('components','组件') |
173 | ->when('every_poem', function (Form\BlockForm $form) { | 173 | ->when('every_poem', function (Form\BlockForm $form) { |
174 | - $form->select('pos_every_poem', '每日位置')->options([ | 174 | + $form->select('pos_every_poem', '每日位置')->options(VideoTemp::POSITION_OPTIONS); |
175 | - 'topLeft'=>'上左','topMiddle'=>'上中','topRight'=>'上右', | ||
176 | - ]); | ||
177 | $form->divider(); | 175 | $form->divider(); |
178 | }) | 176 | }) |
179 | ->when('one_poem', function (Form\BlockForm $form) { | 177 | ->when('one_poem', function (Form\BlockForm $form) { |
180 | - $form->select('pos_one_poem', '一言位置')->options([ | 178 | + $form->select('pos_one_poem', '一言位置')->options(VideoTemp::POSITION_OPTIONS); |
181 | - 'topLeft'=>'上左','topMiddle'=>'上中','topRight'=>'上右', | ||
182 | - ]); | ||
183 | $form->divider(); | 179 | $form->divider(); |
184 | }) | 180 | }) |
185 | ->when('weather', function (Form\BlockForm $form) { | 181 | ->when('weather', function (Form\BlockForm $form) { |
186 | - $form->select('pos_weather', '天气位置')->options([ | 182 | + $form->select('pos_weather', '天气位置')->options(VideoTemp::POSITION_OPTIONS); |
187 | - 'topLeft'=>'上左','topMiddle'=>'上中','topRight'=>'上右', | ||
188 | - ]); | ||
189 | $form->divider(); | 183 | $form->divider(); |
190 | }) | 184 | }) |
191 | ->when('date', function (Form\BlockForm $form) { | 185 | ->when('date', function (Form\BlockForm $form) { |
192 | - $form->select('pos_date', '日期位置')->options([ | 186 | + $form->select('pos_date', '日期位置')->options(VideoTemp::POSITION_OPTIONS); |
193 | - 'topLeft'=>'上左','topMiddle'=>'上中','topRight'=>'上右', | ||
194 | - ]); | ||
195 | $form->divider(); | 187 | $form->divider(); |
196 | }) | 188 | }) |
197 | ->when('feel', function (Form\BlockForm $form) { | 189 | ->when('feel', function (Form\BlockForm $form) { |
198 | - $form->select('pos_feel', '有感位置')->options([ | 190 | + $form->select('pos_feel', '有感位置')->options(VideoTemp::POSITION_OPTIONS); |
199 | - 'topLeft'=>'上左','topMiddle'=>'上中','topRight'=>'上右', | ||
200 | - ]); | ||
201 | $form->divider(); | 191 | $form->divider(); |
202 | }) | 192 | }) |
203 | ->default(['one_poem','weather','date']) | 193 | ->default(['one_poem','weather','date']) |
... | @@ -228,7 +218,7 @@ class VideoTempController extends AdminController | ... | @@ -228,7 +218,7 @@ class VideoTempController extends AdminController |
228 | public function store() | 218 | public function store() |
229 | { | 219 | { |
230 | $all = \request()->all(); | 220 | $all = \request()->all(); |
231 | - dd($all); | 221 | + |
232 | try{ | 222 | try{ |
233 | DB::transaction(function ()use ($all){ | 223 | DB::transaction(function ()use ($all){ |
234 | $vide_temp = VideoTemp::query()->create([ | 224 | $vide_temp = VideoTemp::query()->create([ | ... | ... |
app/Admin/Repositories/AdminMakeVideo.php
0 → 100755
1 | +<?php | ||
2 | + | ||
3 | +namespace App\Admin\Repositories; | ||
4 | + | ||
5 | +use App\Models\AdminMakeVideo as Model; | ||
6 | +use Dcat\Admin\Repositories\EloquentRepository; | ||
7 | + | ||
8 | +class AdminMakeVideo extends EloquentRepository | ||
9 | +{ | ||
10 | + /** | ||
11 | + * Model. | ||
12 | + * | ||
13 | + * @var string | ||
14 | + */ | ||
15 | + protected $eloquentClass = Model::class; | ||
16 | +} |
... | @@ -27,7 +27,7 @@ Route::group([ | ... | @@ -27,7 +27,7 @@ Route::group([ |
27 | /** 临境*/ | 27 | /** 临境*/ |
28 | $router->group(['prefix'=>'/linjing'],function (Router $router){ | 28 | $router->group(['prefix'=>'/linjing'],function (Router $router){ |
29 | $router->resource('/template', 'VideoTempController'); | 29 | $router->resource('/template', 'VideoTempController'); |
30 | - $router->resource('/official', 'VideoShowController'); | 30 | + $router->resource('/official', 'AdminMakeVideoController'); |
31 | }); | 31 | }); |
32 | 32 | ||
33 | /** 订单*/ | 33 | /** 订单*/ | ... | ... |
app/Jobs/MakeVideo.php
0 → 100644
This diff is collapsed. Click to expand it.
app/Models/AdminMakeVideo.php
0 → 100755
1 | +<?php | ||
2 | + | ||
3 | +namespace App\Models; | ||
4 | + | ||
5 | +use Dcat\Admin\Traits\HasDateTimeFormatter; | ||
6 | + | ||
7 | +use Illuminate\Database\Eloquent\Model; | ||
8 | + | ||
9 | +class AdminMakeVideo extends Model | ||
10 | +{ | ||
11 | + use HasDateTimeFormatter; | ||
12 | + protected $table = 'admin_make_video'; | ||
13 | + | ||
14 | + protected $guarded = ['']; | ||
15 | +} |
... | @@ -51,6 +51,7 @@ class Order extends Model | ... | @@ -51,6 +51,7 @@ class Order extends Model |
51 | 51 | ||
52 | public function timeoutCanceled() | 52 | public function timeoutCanceled() |
53 | { | 53 | { |
54 | - | 54 | + $this->status = self::TIMEOUT_CANCEL; |
55 | + $this->save(); | ||
55 | } | 56 | } |
56 | } | 57 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -9,6 +9,13 @@ use Illuminate\Database\Eloquent\Model; | ... | @@ -9,6 +9,13 @@ use Illuminate\Database\Eloquent\Model; |
9 | class VideoTemp extends Model | 9 | class VideoTemp extends Model |
10 | { | 10 | { |
11 | use HasDateTimeFormatter; | 11 | use HasDateTimeFormatter; |
12 | + | ||
13 | + const POSITION_OPTIONS = [ | ||
14 | + 'topLeft'=>'上左','topMiddle'=>'上中','topRight'=>'上右', | ||
15 | + 'midLeft'=>'中左','midMiddle'=>'中中','midRight'=>'中右', | ||
16 | + 'botLeft'=>'下左','botMiddle'=>'下中','botRight'=>'下右', | ||
17 | + ]; | ||
18 | + | ||
12 | protected $table = 'video_temp'; | 19 | protected $table = 'video_temp'; |
13 | 20 | ||
14 | protected $guarded = ['']; | 21 | protected $guarded = ['']; | ... | ... |
... | @@ -221,7 +221,7 @@ return [ | ... | @@ -221,7 +221,7 @@ return [ |
221 | 'Queue' => Illuminate\Support\Facades\Queue::class, | 221 | 'Queue' => Illuminate\Support\Facades\Queue::class, |
222 | 'RateLimiter' => Illuminate\Support\Facades\RateLimiter::class, | 222 | 'RateLimiter' => Illuminate\Support\Facades\RateLimiter::class, |
223 | 'Redirect' => Illuminate\Support\Facades\Redirect::class, | 223 | 'Redirect' => Illuminate\Support\Facades\Redirect::class, |
224 | - // 'Redis' => Illuminate\Support\Facades\Redis::class, | 224 | + 'Redis' => Illuminate\Support\Facades\Redis::class, |
225 | 'Request' => Illuminate\Support\Facades\Request::class, | 225 | 'Request' => Illuminate\Support\Facades\Request::class, |
226 | 'Response' => Illuminate\Support\Facades\Response::class, | 226 | 'Response' => Illuminate\Support\Facades\Response::class, |
227 | 'Route' => Illuminate\Support\Facades\Route::class, | 227 | 'Route' => Illuminate\Support\Facades\Route::class, | ... | ... |
1 | +<?php | ||
2 | + | ||
3 | +use Illuminate\Support\Facades\Schema; | ||
4 | +use Illuminate\Database\Schema\Blueprint; | ||
5 | +use Illuminate\Database\Migrations\Migration; | ||
6 | + | ||
7 | +class CreateAdminMakeVideoTable extends Migration | ||
8 | +{ | ||
9 | + /** | ||
10 | + * Run the migrations. | ||
11 | + * | ||
12 | + * @return void | ||
13 | + */ | ||
14 | + public function up() | ||
15 | + { | ||
16 | + Schema::create('admin_make_video', function (Blueprint $table) { | ||
17 | + $table->increments('id'); | ||
18 | + $table->string('poem_id')->default('')->comment('一言id'); | ||
19 | + $table->unsignedTinyInteger('type')->comment('类型'); | ||
20 | + $table->string('video_url')->nullable()->comment('视频地址'); | ||
21 | + $table->string('images_url')->nullable()->comment('图片地址'); | ||
22 | + $table->unsignedTinyInteger('bg_music')->comment('是否背景音'); | ||
23 | + $table->string('bgm_url')->nullable()->comment('背景音地址'); | ||
24 | + $table->string('feel')->default('')->comment('有感'); | ||
25 | + $table->string('temp_id')->default('')->comment('模板id'); | ||
26 | + $table->unsignedTinyInteger('thumbnail')->comment('封面图'); | ||
27 | + $table->string('thumbnail_url')->nullable()->comment('封面图地址'); | ||
28 | + $table->timestamps(); | ||
29 | + }); | ||
30 | + } | ||
31 | + | ||
32 | + /** | ||
33 | + * Reverse the migrations. | ||
34 | + * | ||
35 | + * @return void | ||
36 | + */ | ||
37 | + public function down() | ||
38 | + { | ||
39 | + Schema::dropIfExists('admin_make_video'); | ||
40 | + } | ||
41 | +} |
-
Please register or login to post a comment