diff --git a/app/Admin/Controllers/CouponController.php b/app/Admin/Controllers/CouponController.php index 0bea57bb..690a2069 100644 --- a/app/Admin/Controllers/CouponController.php +++ b/app/Admin/Controllers/CouponController.php @@ -29,7 +29,7 @@ class CouponController extends AdminController 1 =>'抵扣券', 2 =>'折扣券', ])->label(); - $grid->column('value')->display(function ($value) { + $grid->column('amount')->display(function ($value) { if ($this->type == 1) { return $value.'元'; } elseif ($this->type == 2) { @@ -82,7 +82,7 @@ class CouponController extends AdminController $show->field('id'); $show->field('name'); $show->field('type'); - $show->field('value'); + $show->field('amount'); $show->field('threshold'); $show->field('limit'); $show->field('sent'); @@ -105,29 +105,29 @@ class CouponController extends AdminController $form->display('id'); $form->text('name')->required(); $form->radio('type') - ->when(1, function (Form $form) { - $form->currency('value1')->symbol('¥')->help('例:100.00表示优惠100元。')->value($form->model()->value); - }) - ->when(2, function (Form $form) { - $form->currency('value2')->symbol('%')->help('例:0.95表示95折。')->value($form->model()->value); - }) - ->options([ - 1 =>'抵扣券', - 2 =>'折扣券', - ])->default(1); + ->when(1, function (Form $form) { + $form->currency('amount1')->symbol('¥')->help('例:100.00表示优惠100元。')->value($form->model()->amount); + }) + ->when(2, function (Form $form) { + $form->currency('amount2')->symbol('%')->help('例:0.95表示95折。')->value($form->model()->amount); + }) + ->options([ + 1 =>'抵扣券', + 2 =>'折扣券', + ])->default(1); $form->currency('threshold')->symbol('¥')->default(0); $form->number('limit')->default(0); $form->number('use_day')->default(0)->help('单位:天;指领取后几天内有效。'); $form->datetimeRange('use_start_at', 'use_end_at', '使用时间')->help('设置时间后,期限字段失效。'); - $form->hidden('value'); + $form->hidden('amount'); $form->saving(function (Form $form) { - $value = 'value'.$form->type; - $form->value = $form->$value; + $amount = 'amount'.$form->type; + $form->amount = $form->$amount; - $form->deleteInput('value1'); - $form->deleteInput('value2'); + $form->deleteInput('amount1'); + $form->deleteInput('amount2'); }); $form->display('created_at'); diff --git a/app/Models/Coupon.php b/app/Models/Coupon.php index 8b1d11b2..ba11cc6d 100644 --- a/app/Models/Coupon.php +++ b/app/Models/Coupon.php @@ -13,7 +13,7 @@ class Coupon extends Model use HasDateTimeFormatter; protected $casts = [ - 'value' => Price::class, + 'amount' => Price::class, 'threshold'=>Price::class, ]; diff --git a/database/migrations/2021_12_07_102419_create_coupons_table.php b/database/migrations/2021_12_07_102419_create_coupons_table.php index b4f32e1b..ea0a6a58 100644 --- a/database/migrations/2021_12_07_102419_create_coupons_table.php +++ b/database/migrations/2021_12_07_102419_create_coupons_table.php @@ -18,7 +18,7 @@ class CreateCouponsTable extends Migration $table->string('name')->comment('优惠券名称'); $table->text('description')->nullable()->comment('优惠券说明'); $table->tinyInteger('type')->default(0)->unsigned()->comment('优惠券类型:1抵扣券,2折扣券'); - $table->unsignedInteger('value')->default(0)->comment('抵扣金额:分/折扣(100)'); + $table->unsignedInteger('amount')->default(0)->comment('抵扣金额:分/折扣(100)'); $table->unsignedBigInteger('threshold')->default(0)->comment('使用门槛金额:分'); $table->unsignedInteger('limit')->default(0)->comment('限量'); $table->unsignedInteger('sent')->default(0)->comment('已送数量'); diff --git a/resources/lang/zh_CN/coupon.php b/resources/lang/zh_CN/coupon.php index fc23bcca..cf32acc3 100644 --- a/resources/lang/zh_CN/coupon.php +++ b/resources/lang/zh_CN/coupon.php @@ -11,9 +11,9 @@ return [ ], 'name' => '名称', 'type' => '券类型', - 'value' => '力度', - 'value1'=>'抵扣金额', - 'value2'=>'折扣', + 'amount' => '力度', + 'amount1'=>'抵扣金额', + 'amount2'=>'折扣', 'threshold' => '使用门槛', 'limit' => '限量', 'sent' => '已发',