BatchEditEpisodeForm.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace App\Admin\Actions\Form;
  3. use App\Models\Episode;
  4. use Dcat\Admin\Contracts\LazyRenderable;
  5. use Dcat\Admin\Traits\LazyWidget;
  6. use Dcat\Admin\Widgets\Form;
  7. class BatchEditEpisodeForm extends Form implements LazyRenderable
  8. {
  9. use LazyWidget;
  10. public function handle(array $input)
  11. {
  12. // 选择的行
  13. $ids = explode(',',$input['id']??null);
  14. if(empty($ids)){
  15. return $this->response()->error('参数错误');
  16. }
  17. foreach ($ids as $id){
  18. Episode::where('id' , $id)->update([
  19. 'is_opend' => $input['is_opend'],
  20. 'is_vip_watch' => $input['is_vip_watch'],
  21. ]);
  22. }
  23. return $this->response()->success('修改成功')->refresh();
  24. }
  25. public function form()
  26. {
  27. $this->radio('is_opend')
  28. ->options(config('global.episode_opend'))
  29. ->default(1);
  30. $this->radio('is_vip_watch')
  31. ->options(config('global.bool_status'))
  32. ->default(1);
  33. $this->hidden('id')->attribute('id','batch-id');
  34. }
  35. public function default()
  36. {
  37. }
  38. }