From 662bb57ddba7ae849ee81427578fd11dbc51f68f Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Thu, 23 Dec 2021 21:09:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=A0=87=E7=AD=BE=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/TagController.php | 19 ++++++++++--------- app/Models/Tag.php | 9 +++++++-- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/app/Admin/Controllers/TagController.php b/app/Admin/Controllers/TagController.php index e66087c9..e4b425f6 100644 --- a/app/Admin/Controllers/TagController.php +++ b/app/Admin/Controllers/TagController.php @@ -4,6 +4,7 @@ namespace App\Admin\Controllers; use App\Admin\Repositories\Tag; use App\Exceptions\BizException; +use App\Models\Tag as TagModel; use App\Models\Taggable; use Dcat\Admin\Admin; use Dcat\Admin\Form; @@ -24,9 +25,9 @@ class TagController extends AdminController return Grid::make(new Tag(), function (Grid $grid) { $grid->column('id')->sortable(); $grid->column('type')->using([ - 1=>'订单', - 2=>'货运', - 3=>'售后', + TagModel::TYPE_ORDER =>'订单', + TagModel::TYPE_PACKAGE=>'货运', + // TagModel::TYPE_AFTER_SALE=>'售后', ])->label(); $grid->column('name'); $grid->column('created_at')->sortable(); @@ -52,9 +53,9 @@ class TagController extends AdminController $filter->panel(); $filter->expand(false); $filter->equal('type')->select([ - 1=>'订单', - 2=>'货运', - 3=>'售后', + TagModel::TYPE_ORDER =>'订单', + TagModel::TYPE_PACKAGE =>'货运', + // 3=>'售后', ])->width(3); }); }); @@ -89,9 +90,9 @@ class TagController extends AdminController $type = Request::Input('type', 0); $form->display('id'); $form->radio('type')->options([ - 1=>'订单', - 2=>'货运', - 3=>'售后', + TagModel::TYPE_ORDER =>'订单', + TagModel::TYPE_PACKAGE=>'货运', + // 3=>'售后', ])->default($type)->required(); $form->text('name')->required(); diff --git a/app/Models/Tag.php b/app/Models/Tag.php index 2f5fe43e..97ebf6f2 100644 --- a/app/Models/Tag.php +++ b/app/Models/Tag.php @@ -11,6 +11,11 @@ class Tag extends Model use HasFactory; use HasDateTimeFormatter; + public const TYPE_ORDER = 1; + public const TYPE_PACKAGE = 2; + public const TYPE_AFTER_SALE = 3; + + // /** // * 标签下的订单 // * @@ -31,11 +36,11 @@ class Tag extends Model public function scopeOrderTag() { - return $this->where('type', 1); + return $this->where('type', self::TYPE_ORDER); } public function scopeOrderPackageTag() { - return $this->where('type', 2); + return $this->where('type', self::TYPE_PACKAGE); } }