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.
		
		
		
		
		
			
		
			
				
					
					
						
							433 lines
						
					
					
						
							16 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							433 lines
						
					
					
						
							16 KiB
						
					
					
				
								<?php
							 | 
						|
								
							 | 
						|
								namespace App\AdminAgent\Controllers;
							 | 
						|
								
							 | 
						|
								use App\AdminAgent\Renderable\SelectGuide;
							 | 
						|
								use App\AdminAgent\Renderable\SelectProduct;
							 | 
						|
								use App\AdminAgent\Repositories\AgentProduct;
							 | 
						|
								use App\Common\AgentType;
							 | 
						|
								use App\Common\ProductStatus;
							 | 
						|
								use App\Models\AgentProductItem;
							 | 
						|
								use App\Models\Category;
							 | 
						|
								use App\Models\Channel;
							 | 
						|
								use App\Models\Guide;
							 | 
						|
								use App\Models\Product;
							 | 
						|
								use App\Models\Supplier;
							 | 
						|
								use Dcat\Admin\Admin;
							 | 
						|
								use Dcat\Admin\Form;
							 | 
						|
								use Dcat\Admin\Grid;
							 | 
						|
								use Dcat\Admin\Show;
							 | 
						|
								use Dcat\Admin\Http\Controllers\AdminController;
							 | 
						|
								use Dcat\Admin\Widgets\Alert;
							 | 
						|
								
							 | 
						|
								class AgentProductController extends AdminController
							 | 
						|
								{
							 | 
						|
								    /**
							 | 
						|
								     * Make a grid builder.
							 | 
						|
								     *
							 | 
						|
								     * @return Grid
							 | 
						|
								     */
							 | 
						|
								    protected function grid()
							 | 
						|
								    {
							 | 
						|
								        return Grid::make(new AgentProduct(['product.supplier:id,name', 'category:id,name']), function (Grid $grid) {
							 | 
						|
											$agent_id = Admin::user()->id;
							 | 
						|
								        	$grid->model()->where('agent_id', $agent_id);
							 | 
						|
								
							 | 
						|
								            $grid->column('id')->sortable();
							 | 
						|
								            $grid->column('picture', '产品图片')->image('', 60, 60);
							 | 
						|
								            $grid->column('title', '产品名称')->limit(15);
							 | 
						|
								            $grid->column('price');
							 | 
						|
								            $grid->column('original_price');
							 | 
						|
								            $grid->column('sale');
							 | 
						|
								            $grid->column('stock')->editable();
							 | 
						|
								
							 | 
						|
											$channels = Channel::where('agent_id', $agent_id)->pluck('name', 'id')->toArray();
							 | 
						|
											$grid->column('channel_id', '频道')
							 | 
						|
												->display(function ($modal) use ($channels) {
							 | 
						|
													$data = array_flip(explode(',', $this->channel_id));
							 | 
						|
													return join(',',array_intersect_key($channels, $data));
							 | 
						|
												})
							 | 
						|
												->limit(10);
							 | 
						|
											$grid->column('category.name', '分类');
							 | 
						|
											/*$grid->column('product_ids', '产品详情')
							 | 
						|
												->display('查看')
							 | 
						|
												->modal(function ($modal) {
							 | 
						|
													$titles = ['供应商', '产品标题', '产品图片', '原价', '现价', '销量', '库存'];
							 | 
						|
													$pic = isset($this->product->picture)
							 | 
						|
														? "<img data-action=\"preview-img\" src=\"{$this->product->picture}\" style=\"max-width:80px;max-height:200px;cursor:pointer\" class=\"img img-thumbnail\">"
							 | 
						|
														: '';
							 | 
						|
													$data = [[
							 | 
						|
														$this->product->supplier->name ?? '',
							 | 
						|
														$this->product->title ?? '',
							 | 
						|
														$pic,
							 | 
						|
														$this->product->original_price ?? '',
							 | 
						|
														$this->product->price ?? '',
							 | 
						|
														$this->product->sale ?? '',
							 | 
						|
														$this->product->stock ?? '',
							 | 
						|
													]];
							 | 
						|
													return Table::make($titles, $data);
							 | 
						|
												});*/
							 | 
						|
								
							 | 
						|
											$grid->column('status')->help('切换开关可改变上下架状态')
							 | 
						|
												->if(fn() => in_array($this->status, [ProductStatus::SOLD_OUT, ProductStatus::ON_SALE]))
							 | 
						|
												->using([ProductStatus::SOLD_OUT => 0, ProductStatus::ON_SALE => 1])
							 | 
						|
												->switch()
							 | 
						|
												->else()
							 | 
						|
												->using(ProductStatus::array());
							 | 
						|
											$grid->column('is_rec')->switch()->help('推荐后将在“我的”页面下方显示');
							 | 
						|
								            $grid->column('updated_at');
							 | 
						|
								
							 | 
						|
								            $grid->filter(function (Grid\Filter $filter) {
							 | 
						|
												$filter->panel();
							 | 
						|
								
							 | 
						|
												$filter->model()->where('agent_id', Admin::user()->id);
							 | 
						|
								
							 | 
						|
												$filter->equal('id')->width(2);
							 | 
						|
												$filter->like('product.title', '产品标题')->width(3);
							 | 
						|
												$filter->equal('status')->select(ProductStatus::array())->width(2);
							 | 
						|
								
							 | 
						|
												$options = Supplier::where('status', 1)->pluck('name', 'id')->toArray();
							 | 
						|
												$filter->equal('product.supplier_Id', '供应商')->select($options)->width(2);
							 | 
						|
								            });
							 | 
						|
								        });
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    /**
							 | 
						|
								     * Make a show builder.
							 | 
						|
								     *
							 | 
						|
								     * @param mixed $id
							 | 
						|
								     *
							 | 
						|
								     * @return Show
							 | 
						|
								     */
							 | 
						|
								    protected function detail($id)
							 | 
						|
								    {
							 | 
						|
								        return Show::make($id, new AgentProduct(['agent:id,name', 'product.supplier:id,name', 'user:id,nickname', 'guide:id,name']), function (Show $show) {
							 | 
						|
											//不允许查看非自己的数据
							 | 
						|
											if ($show->model()->agent_id != Admin::user()->id) {
							 | 
						|
												Admin::exit('数据不存在');
							 | 
						|
											}
							 | 
						|
								
							 | 
						|
											$show->field('id');
							 | 
						|
								            $show->field('agent_id');
							 | 
						|
								            $show->field('product_id');
							 | 
						|
								            $show->field('price');
							 | 
						|
								            $show->field('original_price');
							 | 
						|
								            $show->field('sale');
							 | 
						|
								            $show->field('stock');
							 | 
						|
								            $show->field('channel_id');
							 | 
						|
								            $show->field('category_id');
							 | 
						|
								            $show->field('status')->using(ProductStatus::array());
							 | 
						|
											$show->field('verifier.nickname', '核销人员');
							 | 
						|
											if (Admin::user()->type == AgentType::CLUSTER) {
							 | 
						|
												$show->field('guide.name', '地接');
							 | 
						|
											}
							 | 
						|
								            $show->field('is_rec')->using(['未推荐', '已推荐']);
							 | 
						|
								            $show->field('title');
							 | 
						|
								            $show->field('pictures')->image('', 80, 80);
							 | 
						|
								            $show->field('know')->unescape();
							 | 
						|
								            $show->field('content')->unescape();
							 | 
						|
								            $show->field('earnest');
							 | 
						|
								            $show->field('earnest_timeout');
							 | 
						|
								            $show->field('deposit');
							 | 
						|
								            $show->field('deposit_timeout');
							 | 
						|
								            $show->field('created_at');
							 | 
						|
								            $show->field('updated_at');
							 | 
						|
								
							 | 
						|
											$show->html(Alert::make(null, '供应商产品详情')->info());
							 | 
						|
								
							 | 
						|
											$show->field('product.id', '供应商产品ID');
							 | 
						|
											$show->field('product.supplier.name');
							 | 
						|
											$show->field('product.title');
							 | 
						|
											$show->field('product.pictures')->image('', 80, 80);
							 | 
						|
											$show->field('product.original_price');
							 | 
						|
											$show->field('product.price');
							 | 
						|
											$show->field('product.sale');
							 | 
						|
											$show->field('product.stock');
							 | 
						|
											$show->field('product.created_at', '创建时间');
							 | 
						|
											$show->field('product.updated_at', '更新时间');
							 | 
						|
										});
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    /**
							 | 
						|
								     * Make a form builder.
							 | 
						|
								     *
							 | 
						|
								     * @return Form
							 | 
						|
								     */
							 | 
						|
								    protected function form()
							 | 
						|
								    {
							 | 
						|
								        return Form::make(new AgentProduct(), function (Form $form) {
							 | 
						|
											$agent_id = Admin::user()->id;
							 | 
						|
											//不允许查看非自己的数据
							 | 
						|
											if ($form->isEditing() && $form->model()->agent_id != Admin::user()->id) {
							 | 
						|
												return $form->response()->error('数据不存在');
							 | 
						|
											}
							 | 
						|
								
							 | 
						|
											$form->display('id');
							 | 
						|
											$form->radio('type')
							 | 
						|
												->options(['单品销售', '组合销售'])
							 | 
						|
												->default(0)->required()
							 | 
						|
												->help('单品销售无需审核,组合销售需要审核才能上架')
							 | 
						|
												->when(0, function (Form $form) {
							 | 
						|
													/** 单品销售 **/
							 | 
						|
													$form->selectTable('product_id', '选择产品')
							 | 
						|
														->help('产品列表显示的是该产品的标题和图片')
							 | 
						|
														->title('选择产品')
							 | 
						|
														->dialogWidth('80%;min-width:825px;')
							 | 
						|
														->from(SelectProduct::make())
							 | 
						|
														->model(Product::class);
							 | 
						|
												})->when(1, function (Form $form) {
							 | 
						|
													/** 组合销售 **/
							 | 
						|
													$form->multipleSelectTable('product_ids', '选择产品')
							 | 
						|
														->help('可单选或多选组合销售')
							 | 
						|
														->title('选择产品')
							 | 
						|
														->dialogWidth('80%;min-width:825px;')
							 | 
						|
														->from(SelectProduct::make())
							 | 
						|
														->model(Product::class);
							 | 
						|
								
							 | 
						|
													/** 自定义内容 **/
							 | 
						|
													$form->text('title');
							 | 
						|
													$form->multipleImage('pictures')->removable(false)->uniqueName();
							 | 
						|
													$form->editor('know');
							 | 
						|
													$form->editor('content');
							 | 
						|
												});
							 | 
						|
											$form->text('price')->required();
							 | 
						|
								            $form->text('original_price')->required();
							 | 
						|
								            $form->text('sale')->default(0);
							 | 
						|
								            $form->text('stock')->default(8888)->required();
							 | 
						|
								
							 | 
						|
											$options = Channel::selectOptions(fn($query) => $query->where('agent_id', $agent_id));
							 | 
						|
											$form->multipleSelect('channel_id')->options(array_slice($options, 1, null, true));
							 | 
						|
								
							 | 
						|
											$options = Category::selectOptions(fn($query) => $query->where('agent_id', $agent_id));
							 | 
						|
								            $form->select('category_id')
							 | 
						|
												->options(array_slice($options, 1, null, true))
							 | 
						|
												->required();
							 | 
						|
								
							 | 
						|
								            if ($form->isEditing() && in_array($form->model()->status, [ProductStatus::UNAUDITED, ProductStatus::REFUSE])) {
							 | 
						|
												$form->display('status')->customFormat(fn($v) => ProductStatus::array()[$form->model()->status]);
							 | 
						|
											} else {
							 | 
						|
												$form->radio('status')
							 | 
						|
													->default(ProductStatus::ON_SALE)
							 | 
						|
													->options([
							 | 
						|
														ProductStatus::ON_SALE => '上架',
							 | 
						|
														ProductStatus::SOLD_OUT => '下架',
							 | 
						|
													])
							 | 
						|
													->required();
							 | 
						|
											}
							 | 
						|
											$form->switch('is_rec')->help('推荐后将在“我的”页面下方显示');
							 | 
						|
											//$form->selectTable('verifier')
							 | 
						|
											//	->title('选择核销人员')
							 | 
						|
											//	->dialogWidth('50%;min-width:600px;') //不起作用
							 | 
						|
											//	->from(SelectUser::make(['is_verify' => 1]))
							 | 
						|
											//	->model(User::class, 'id', 'nickname')
							 | 
						|
											//	->customFormat(fn($v) => !$v ? '' : $v)
							 | 
						|
											//	->required();
							 | 
						|
								
							 | 
						|
											//组团版旅行社可以选择地接
							 | 
						|
											if (Admin::user()->type == AgentType::CLUSTER) {
							 | 
						|
												$form->selectTable('guide_id', '地接人员')
							 | 
						|
													->title('选择地接人员')
							 | 
						|
													->dialogWidth('50%;min-width:600px;') //不起作用
							 | 
						|
													->from(SelectGuide::make())
							 | 
						|
													->model(Guide::class, 'id', 'name');
							 | 
						|
											}
							 | 
						|
								
							 | 
						|
											$form->number('earnest')->width(2)->default(0)->help('单位:元。不输入或输入 0 则不支持定金支付,必须和定金超时时间同时设置才会生效');
							 | 
						|
											$form->number('earnest_timeout')->width(2)->default(0)->help('单位:分钟。超过这个时间未支付,订单将自动关闭');
							 | 
						|
											$form->number('deposit')->default(0)->help('单位:元。不输入或输入 0 则不支持订金支付,必须和订金超时时间同时设置才会生效');
							 | 
						|
											$form->number('deposit_timeout')->default(0)->help('单位:分钟。超过这个时间未支付,订单将自动关闭');
							 | 
						|
								        })->saving(function (Form $form) {
							 | 
						|
											//不允许修改非自己的数据
							 | 
						|
											if ($form->isEditing() && $form->model()->agent_id != Admin::user()->id) {
							 | 
						|
												return $form->response()->error('数据不存在');
							 | 
						|
											}
							 | 
						|
								
							 | 
						|
											if ($form->isEditing() && $form->product_id === null && $form->product_ids === null) {
							 | 
						|
												//推荐按钮开关
							 | 
						|
												if ($form->is_rec !== null) {
							 | 
						|
													$form->model()->is_rec = $form->is_rec ? 1 : 0;
							 | 
						|
													$form->model()->save();
							 | 
						|
													return $form->response()->success('更新成功!');
							 | 
						|
												}
							 | 
						|
								
							 | 
						|
												if ($form->stock !== null || $form->status !== null) {
							 | 
						|
													$ids = explode(',', $form->model()->product_ids);
							 | 
						|
													$count = Product::where([['status', '=', ProductStatus::ON_SALE], ['stock', '>=', $form->model()->stock]])
							 | 
						|
														->whereIn('id', $ids)->count();
							 | 
						|
													if (count($ids) != $count) {
							 | 
						|
														return $form->response()->error('供应商产品已下架或库存不足!');
							 | 
						|
													}
							 | 
						|
								
							 | 
						|
													//修改库存
							 | 
						|
													if ($form->stock !== null) {
							 | 
						|
														$form->model()->stock = $form->stock;
							 | 
						|
														$form->model()->save();
							 | 
						|
														return $form->response()->success('更新成功!');
							 | 
						|
													}
							 | 
						|
													//上下架状态按钮开关
							 | 
						|
													if ($form->status !== null) {
							 | 
						|
														//待审核和拒绝的状态不允许修改
							 | 
						|
														if (in_array($form->model()->status, [ProductStatus::UNAUDITED, ProductStatus::REFUSE])) {
							 | 
						|
															return $form->response()->error('产品待审核或审核拒绝,不允许修改!');
							 | 
						|
														}
							 | 
						|
														$form->model()->status = $form->status == 1 ? ProductStatus::ON_SALE : ProductStatus::SOLD_OUT;
							 | 
						|
														$form->model()->save();
							 | 
						|
														return $form->response()->success('更新成功!');
							 | 
						|
													}
							 | 
						|
												}
							 | 
						|
											}
							 | 
						|
								
							 | 
						|
											if (is_null($form->type)) {
							 | 
						|
												return $form->response()->error('请选择销售类型!');
							 | 
						|
											}
							 | 
						|
											//单品销售
							 | 
						|
											if ($form->type == 0) {
							 | 
						|
												$form->product_id = (int)$form->product_id;
							 | 
						|
												if (!$form->product_id) {
							 | 
						|
													return $form->response()->error('请选择产品');
							 | 
						|
												}
							 | 
						|
												$form->product_ids =  $form->product_id;
							 | 
						|
								
							 | 
						|
												//将供应商产品写入title,pictures,know,content
							 | 
						|
												$product = Product::find($form->product_id);
							 | 
						|
												if ($product->status != ProductStatus::ON_SALE) {
							 | 
						|
													return $form->response()->error('产品ID '. $form->product_id .' 已下架');
							 | 
						|
												} else if ($product->stock < $form->stock) {
							 | 
						|
													return $form->response()->error("供应商当前库存为{$product->stock},你设置的库存不能超过该数值");
							 | 
						|
												}
							 | 
						|
												$form->title = $product->title;
							 | 
						|
												$form->pictures = $product->pictures;
							 | 
						|
												$form->know = $product->know;
							 | 
						|
												$form->content = $product->content;
							 | 
						|
											}
							 | 
						|
											//组合销售
							 | 
						|
											else if ($form->type == 1) {
							 | 
						|
												if (!$form->product_ids) {
							 | 
						|
													return $form->response()->error('请选择产品');
							 | 
						|
												}
							 | 
						|
												$product_ids = explode(',', $form->product_ids);
							 | 
						|
								
							 | 
						|
												if (count($product_ids) < 2) {
							 | 
						|
													return $form->response()->error('组合销售必须选择两个以上产品,否则请选择单品销售');
							 | 
						|
												}
							 | 
						|
												$form->product_id = $product_ids[0];
							 | 
						|
								
							 | 
						|
												$required_fields = ['title', 'pictures', 'know', 'content'];
							 | 
						|
												foreach ($required_fields as $field) {
							 | 
						|
													if (!$form->$field) {
							 | 
						|
														return $form->response()->error('内容输入不完整,标题、产品图片、旅游须知、产品详情必填');
							 | 
						|
													}
							 | 
						|
												}
							 | 
						|
								
							 | 
						|
												//判断供应商产品是否存在或下架
							 | 
						|
												$not_in_id = Product::query()
							 | 
						|
													->whereIn('id', $product_ids)
							 | 
						|
													->where(function ($query) use ($form) {
							 | 
						|
														$query->where('status', '<>', ProductStatus::ON_SALE)
							 | 
						|
															->orWhere('stock', '<', $form->stock);
							 | 
						|
													})
							 | 
						|
													->pluck('id')
							 | 
						|
													->toArray();
							 | 
						|
												if ($not_in_id) {
							 | 
						|
													return $form->response()->error('产品ID ' . join(',', $not_in_id) . ' 库存小于你设置的库存' . $form->stock . ',或不存在、已下架等');
							 | 
						|
												}
							 | 
						|
											} else {
							 | 
						|
												return $form->response()->error('不存在此销售方式');
							 | 
						|
											}
							 | 
						|
								
							 | 
						|
											$agent_id = Admin::user()->id;
							 | 
						|
											//处理特殊字段
							 | 
						|
											$form->hidden(['agent_id', 'status']); //表单没有的字段,必须加这句才能够重写
							 | 
						|
											$form->agent_id = $agent_id;
							 | 
						|
											if (array_key_exists('guide_id', $form->input())) {
							 | 
						|
												$form->guide_id = $form->guide_id ?? 0;
							 | 
						|
											}
							 | 
						|
											//组合销售需要审核,编辑时是否需要审核在saved里面判断
							 | 
						|
											if ($form->type == 1) {
							 | 
						|
												if ($form->isCreating()) {
							 | 
						|
													$form->status = ProductStatus::UNAUDITED;
							 | 
						|
												} else if ($form->isEditing() && in_array($form->model()->status, [ProductStatus::UNAUDITED, ProductStatus::REFUSE])) {
							 | 
						|
													$form->deleteInput('status'); //待审核和拒绝的状态不允许修改
							 | 
						|
												}
							 | 
						|
											} else {
							 | 
						|
												$form->status = $form->status == ProductStatus::ON_SALE ? ProductStatus::ON_SALE : ProductStatus::SOLD_OUT;
							 | 
						|
											}
							 | 
						|
								
							 | 
						|
											//订金
							 | 
						|
											if ($form->earnest <= 0 || $form->earnest_timeout <= 0) {
							 | 
						|
												$form->earnest = 0;
							 | 
						|
												$form->earnest_timeout = 0;
							 | 
						|
											} else if ($form->earnest > $form->price) {
							 | 
						|
												return $form->response()->error('订金不能大于商品价');
							 | 
						|
											}
							 | 
						|
								
							 | 
						|
											//定金
							 | 
						|
											if ($form->deposit <= 0 || $form->deposit_timeout <= 0) {
							 | 
						|
												$form->deposit = 0;
							 | 
						|
												$form->deposit_timeout = 0;
							 | 
						|
											} else if ($form->earnest > $form->price) {
							 | 
						|
												return $form->response()->error('定金不能大于商品价');
							 | 
						|
											}
							 | 
						|
								
							 | 
						|
											//不允许编辑的字段
							 | 
						|
											$form->ignore(['id', 'agent_id', 'status', 'created_at', 'updated_at', 'deleted_at']);
							 | 
						|
								
							 | 
						|
											//判断是否重复发布产品
							 | 
						|
											$where = [
							 | 
						|
												['agent_id', '=', $agent_id],
							 | 
						|
												['product_id', '=', $form->product_id],
							 | 
						|
												['product_ids', '=', $form->product_ids],
							 | 
						|
											];
							 | 
						|
											if ($form->isEditing()) {
							 | 
						|
												$where[] = ['id', '<>', $form->getKey()];
							 | 
						|
											}
							 | 
						|
											if ($form->repository()->model()->where($where)->exists()) {
							 | 
						|
												return $form->response()->error('该产品已经存在,请勿重复发布');
							 | 
						|
											}
							 | 
						|
										})->saved(function (Form $form) {
							 | 
						|
											/** 保存到组合产品明细,先查询出之前明细,再跟新的比较,若没有则删除,新的产品原来明细表没有的,则插入 **/
							 | 
						|
											$product_ids = explode(',', $form->product_ids);
							 | 
						|
											$agent_product_id = $form->getKey();
							 | 
						|
								
							 | 
						|
											$product = Product::whereIn('id', $product_ids)->orderBy('id')
							 | 
						|
												->get(['id AS product_id', 'supplier_id'])->toArray();
							 | 
						|
								
							 | 
						|
											$insert_data = array_map(function ($v) use ($agent_product_id) {
							 | 
						|
												$v['agent_product_id'] = $agent_product_id;
							 | 
						|
												$v['agent_id'] = Admin::user()->id;
							 | 
						|
												return $v;
							 | 
						|
											}, $product);
							 | 
						|
								
							 | 
						|
											//组合产品编辑关键字段需要审核
							 | 
						|
											if ($form->isEditing() && $form->model()->wasChanged(['title', 'pictures', 'know', 'content'])) {
							 | 
						|
												$form->model()->update(['status' => ProductStatus::UNAUDITED]);
							 | 
						|
											}
							 | 
						|
								
							 | 
						|
											if ($form->isCreating()) {
							 | 
						|
												AgentProductItem::insert($insert_data);
							 | 
						|
											} else if ($form->isEditing()) {
							 | 
						|
												//删除原来有,但现在没有的数据
							 | 
						|
												AgentProductItem::query()
							 | 
						|
													->where('agent_product_id', $agent_product_id)
							 | 
						|
													->whereNotIn('product_id', $product_ids)->delete();
							 | 
						|
								
							 | 
						|
												//插入原来没有,但是现在有的数据
							 | 
						|
												foreach ($insert_data as $v) {
							 | 
						|
													AgentProductItem::query()->firstOrCreate(
							 | 
						|
														['agent_product_id' => $agent_product_id, 'product_id' => $v['product_id']],
							 | 
						|
														$v
							 | 
						|
													);
							 | 
						|
												}
							 | 
						|
											}
							 | 
						|
										})->deleting(function (Form $form) {
							 | 
						|
											//不允许删除非自己的数据
							 | 
						|
											if (array_filter($form->model()->toArray(), fn($v) => $v['agent_id'] != Admin::user()->id)) {
							 | 
						|
												return $form->response()->error('数据不存在');
							 | 
						|
											}
							 | 
						|
								
							 | 
						|
											//处理组合产品明细表
							 | 
						|
											$ids = array_column($form->model()->toArray(),'id');
							 | 
						|
											AgentProductItem::query()->whereIn('agent_product_id',$ids)->delete();
							 | 
						|
										});
							 | 
						|
								    }
							 | 
						|
								}
							 |