1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?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'],
- ]);
- }
- 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->hidden('id')->attribute('id','batch-id');
- }
- public function default()
- {
- }
- }
|