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.
47 lines
1.1 KiB
47 lines
1.1 KiB
<?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'];
|
|
$spec = ProductSpec::where('product_id', $id);
|
|
if (!empty($input['agent_product_id'])) {
|
|
$agent_spec = AgentProductSpec::where('agent_product_id', $input['agent_product_id'])
|
|
->pluck('product_spec_id')->toArray();
|
|
if ($agent_spec) {
|
|
$spec = $spec->whereNotIn('id', $agent_spec);
|
|
}
|
|
}
|
|
|
|
$spec = $spec->orderBy('name')->orderBy('supplier_date')
|
|
->get([
|
|
'id AS product_spec_id',
|
|
'name AS supplier_name',
|
|
'date AS supplier_date',
|
|
'original_price AS supplier_original_price',
|
|
'price AS supplier_price',
|
|
'cost_price AS supplier_cost_price',
|
|
'stock AS supplier_stock',
|
|
])->toArray();
|
|
|
|
return $this->response()->data($spec);
|
|
}
|
|
|
|
public function form()
|
|
{
|
|
$this->hidden('product_id');
|
|
$this->hidden('agent_product_id');
|
|
}
|
|
}
|