BatchEditEpisodeForm.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. 'platform' => $input['platform'],
  22. ]);
  23. }
  24. return $this->response()->success('修改成功')->refresh();
  25. }
  26. public function form()
  27. {
  28. $this->radio('is_opend')
  29. ->options(config('global.episode_opend'))
  30. ->default(1);
  31. $this->radio('is_vip_watch')
  32. ->options(config('global.bool_status'))
  33. ->default(1);
  34. $this->checkbox('platform')
  35. ->options(config('global.platform'));
  36. $this->hidden('id')->attribute('id', 'batch-id');
  37. }
  38. public function default()
  39. {
  40. }
  41. }