12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace App\Admin\Actions\Form;
- use App\Models\Product;
- use Dcat\Admin\Contracts\LazyRenderable;
- use Dcat\Admin\Traits\LazyWidget;
- use Dcat\Admin\Widgets\Form;
- class BatchEditProductForm 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){
- Product::where('id' , $id)->update([
- 'is_opened' => $input['is_opened'],
- ]);
- }
- return $this->response()->success('修改成功')->refresh();
- }
- public function form()
- {
- $this->radio('is_opened','是否上架')
- ->options(config('global.bool_status'))
- ->default(1);
- $this->hidden('id')->attribute('id','batch-id');
- }
- public function default()
- {
- }
- }
|