12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace App\Admin\Actions\Form;
- use App\Models\Episode;
- use Dcat\Admin\Contracts\LazyRenderable;
- use Dcat\Admin\Traits\LazyWidget;
- use Dcat\Admin\Widgets\Form;
- class BatchEditEpisodeForm extends Form implements LazyRenderable
- {
- use LazyWidget;
- public function handle(array $input)
- {
- // 选择的行
- $ids = explode(',', $input['id'] ?? null);
- if (empty($ids)) {
- return $this->response()->error('参数错误');
- }
- foreach ($ids as $id) {
- Episode::where('id', $id)->update([
- 'is_opend' => $input['is_opend'],
- 'is_vip_watch' => $input['is_vip_watch'],
- 'platform' => $input['platform'],
- ]);
- }
- return $this->response()->success('修改成功')->refresh();
- }
- public function form()
- {
- $this->radio('is_opend')
- ->options(config('global.episode_opend'))
- ->default(1);
- $this->radio('is_vip_watch')
- ->options(config('global.bool_status'))
- ->default(1);
- $this->checkbox('platform')
- ->options(config('global.platform'));
- $this->hidden('id')->attribute('id', 'batch-id');
- }
- public function default()
- {
- }
- }
|