4
0
Fork 0
dcat-admin-goods/src/Form/Goods/AttrForm.php

33 lines
876 B
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 AttrForm extends Form implements LazyRenderable
{
use LazyWidget;
public function handle(array $input)
{
$goods = Goods::findOrFail($this->payload['goods_id']);
$goods->update(['attr' => json_decode($input['attr'])]);
return $this->response()->success('保存成功');
}
public function form()
{
$attr = $this->model()->type?->attr;
$this->spec('attr')->header(['分组', '名称', '属性值'])->type($attr);
}
protected function renderResetButton()
{
return '<a href="javascript:window.history.back()" class="btn btn-white pull-left"><i class="feather icon-arrow-left"></i> 返回</a>';
}
}