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.
|
|
<?php
namespace App\AdminAgent\Forms;
use App\Models\AgentProductSpec;use App\Models\ProductSpec;use Dcat\Admin\Widgets\Form;use Dcat\Admin\Traits\LazyWidget;use Dcat\Admin\Contracts\LazyRenderable;
class LoadSupplierSpec extends Form implements LazyRenderable{ use LazyWidget;
// 处理请求
public function handle(array $input) { $id = $input['product_id']; if (!empty($input['agent_product_id'])) { $agent_spec = AgentProductSpec::where('agent_product_id', $input['agent_product_id']) ->pluck('product_spec_id')->toArray(); $spec = ProductSpec::where('product_id', $id) ->whereNotIn('id', $agent_spec ?? [0]) ->get([ 'id AS product_spec_id', 'name AS supplier_name', 'date AS supplier_date', 'price AS supplier_price', 'stock AS supplier_stock', ])->toArray(); } else { $spec = ProductSpec::where('product_id', $id)->get([ 'id AS product_spec_id', 'name AS supplier_name', 'date AS supplier_date', 'price AS supplier_price', 'stock AS supplier_stock', ])->toArray(); }
return $this->response()->data($spec); }
public function form() { $this->hidden('product_id'); $this->hidden('agent_product_id'); }}
|