43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Peidikeji\Goods\Form\Goods;
|
|
|
|
use Dcat\Admin\Contracts\LazyRenderable;
|
|
use Dcat\Admin\Traits\LazyWidget;
|
|
use Dcat\Admin\Widgets\Form;
|
|
use Peidikeji\Goods\Models\Goods;
|
|
|
|
class PartForm extends Form implements LazyRenderable
|
|
{
|
|
use LazyWidget;
|
|
|
|
public function handle(array $input)
|
|
{
|
|
$goods = Goods::findOrFail($this->payload['goods_id']);
|
|
$part = json_decode($input['part'], true);
|
|
foreach($part as &$item) {
|
|
foreach($item['values'] as &$subItem) {}
|
|
$subItem['value'] = floatval($subItem['value']);
|
|
}
|
|
$goods->update(['part' => $part]);
|
|
return $this->response()->success('保存成功');
|
|
}
|
|
|
|
public function form()
|
|
{
|
|
$part = $this->model()->type?->part;
|
|
|
|
$this->spec('part')->header(['名称', '可选值', '价格'])->type($part);
|
|
}
|
|
|
|
protected function renderResetButton()
|
|
{
|
|
return "<a href=\"javascript:window.history.back()\" class=\"btn btn-white pull-left\"><i class=\"feather icon-arrow-left\"></i> 返回</a>";
|
|
}
|
|
|
|
protected function getSubmitButtonLabel()
|
|
{
|
|
return '保存';
|
|
}
|
|
}
|