SendOrderForm.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace App\Admin\Actions;
  3. use App\Models\Order;
  4. use Dcat\Admin\Contracts\LazyRenderable;
  5. use Dcat\Admin\Traits\LazyWidget;
  6. use Dcat\Admin\Widgets\Form;
  7. class SendOrderForm extends Form implements LazyRenderable
  8. {
  9. use LazyWidget; //0审核中, 1进行中,2不通过, 3已完成
  10. //弹窗表单
  11. public function form()
  12. {
  13. $id = isset($this->payload['id']) ? $this->payload['id'] : 0;
  14. $this->hidden('id')->value($id);
  15. $this->radio('is_send', '')->options([
  16. 1=>'发货'
  17. ])->default(1);
  18. }
  19. //点击表单处理
  20. public function handle(array $input)
  21. {
  22. $is_send = $input['is_send'];
  23. try {
  24. $order = Order::find($input['id']);
  25. if ($is_send > 0) {
  26. $order->is_send = $is_send;
  27. $order->save();
  28. }
  29. } catch (\Exception $exception) {
  30. return $this->response()->error($exception->getMessage());
  31. }
  32. return $this->response()->success('success')->refresh();
  33. }
  34. }