9.2. 秒杀商品管理后台
秒杀商品管理后台
接下来我们需要给秒杀商品创建对应的管理后台。
1. 控制器
由于我们之前封装过后台商品管理的代码,因此不需要通过 make:admin
命令创建控制器了,直接新建一个 SeckillProductsController
类:
$ touch app/Admin/Controllers/SeckillProductsController.php
app/Admin/Controllers/SeckillProductsController.php
<?php
namespace App\Admin\Controllers;
use App\Models\Product;
use Encore\Admin\Form;
use Encore\Admin\Grid;
class SeckillProductsController extends CommonProductsController
{
public function getProductType()
{
return Product::TYPE_SECKILL;
}
protected function customGrid(Grid $grid)
{
$grid->id('ID')->sortable();
$grid->title('商品名称');
$grid->on_sale('已上架')->display(function ($value) {
return $value ? '是' : '否';
});
$grid->...