first
This commit is contained in:
70
modules/Mall/Http/Controllers/Admin/SpecValueController.php
Normal file
70
modules/Mall/Http/Controllers/Admin/SpecValueController.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Mall\Http\Controllers\Admin;
|
||||
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Modules\Mall\Models\Goods;
|
||||
use Modules\Mall\Models\GoodsSpec;
|
||||
use Modules\Mall\Models\GoodsSpecValue;
|
||||
|
||||
class SpecValueController extends Controller
|
||||
{
|
||||
|
||||
public function index(Content $content, Goods $good, GoodsSpec $spec): Content
|
||||
{
|
||||
return $content
|
||||
->header($spec->name)
|
||||
->description('属性值列表')
|
||||
->body($this->grid($spec));
|
||||
}
|
||||
|
||||
public function grid($spec): Grid
|
||||
{
|
||||
$grid = new Grid(new GoodsSpecValue());
|
||||
|
||||
$grid->model()->where('spec_id', $spec->id);
|
||||
$grid->column('value', '属性值');
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
public function create(Content $content, Goods $good, GoodsSpec $spec): Content
|
||||
{
|
||||
return $content
|
||||
->header($spec->name)
|
||||
->description('属性列表')
|
||||
->body($this->form($spec));
|
||||
}
|
||||
|
||||
public function form($spec): Form
|
||||
{
|
||||
$form = new Form(new GoodsSpecValue());
|
||||
|
||||
$form->text('value', '属性值');
|
||||
$form->hidden('spec_id')->value($spec->id);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
public function store(Goods $good, GoodsSpec $spec)
|
||||
{
|
||||
return $this->form($spec)->store();
|
||||
}
|
||||
|
||||
public function edit(Content $content, Goods $good, GoodsSpec $spec, GoodsSpecValue $value): Content
|
||||
{
|
||||
return $content
|
||||
->header($spec->name)
|
||||
->description('属性列表')
|
||||
->body($this->form($spec)->edit($value->id));
|
||||
}
|
||||
|
||||
public function update(Goods $good, GoodsSpec $spec, GoodsSpecValue $value)
|
||||
{
|
||||
return $this->form($spec)->update($value->id);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user