链街Dcat后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.4 KiB

  1. <?php
  2. namespace App\Admin\Forms;
  3. use Dcat\Admin\Widgets\Form;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use App\Models\v3\Store as StoreModel;
  6. use App\Models\v3\Goods as GoodsModel;
  7. use App\Models\v3\GoodsBanners as GoodsBannerModel;
  8. class GoodsCopyForm extends Form
  9. {
  10. /**
  11. * Handle the form request.
  12. *
  13. * @param array $input
  14. *
  15. * @return Response
  16. */
  17. public function handle(array $input)
  18. {
  19. // 获取外部传递参数
  20. $goodsId = $input['goods_id'];
  21. $storeIds= $input['store_ids'];
  22. // dd($storeIds);
  23. $goods = GoodsModel::find($goodsId);
  24. $goodsBanners = GoodsBannerModel::where('goods_id',$goodsId)->get();
  25. foreach($storeIds as $key =>$value){
  26. $model = new GoodsModel();
  27. $model = $goods;
  28. dd($model->toArray());
  29. $model->store_id = $value;
  30. $model->name = $goods->name;
  31. }
  32. return $this->success('修改成功', '/goods');
  33. }
  34. /**
  35. * Build a form here.
  36. */
  37. public function form()
  38. {
  39. $id = $this->getKey();
  40. $this->text('goods_id')->value($id);
  41. $stores = StoreModel::getStoreArray();
  42. $this->multipleSelect('store_ids','选择店铺')->required()->options($stores);
  43. }
  44. /**
  45. * The data of the form.
  46. *
  47. * @return array
  48. */
  49. public function default()
  50. {
  51. return [];
  52. }
  53. }