|
@@ -4,6 +4,7 @@ namespace App\Admin\Controllers\CouponManagement;
|
|
|
|
|
|
use App\Admin\Actions\backstage\Coupon\CouponDetails;
|
|
use App\Admin\Actions\backstage\Coupon\CouponDetails;
|
|
use App\Admin\Actions\backstage\Coupon\CouponDistribution;
|
|
use App\Admin\Actions\backstage\Coupon\CouponDistribution;
|
|
|
|
+use App\Admin\Actions\backstage\Coupon\CouponDistributions;
|
|
use App\Models\Coupon;
|
|
use App\Models\Coupon;
|
|
use Encore\Admin\Controllers\AdminController;
|
|
use Encore\Admin\Controllers\AdminController;
|
|
use Encore\Admin\Form;
|
|
use Encore\Admin\Form;
|
|
@@ -28,13 +29,12 @@ class CouponManagementController extends AdminController
|
|
{
|
|
{
|
|
$grid = new Grid(new Coupon());
|
|
$grid = new Grid(new Coupon());
|
|
|
|
|
|
|
|
+ $grid->tools(function (Grid\Tools $tools) {
|
|
|
|
+ $tools->append(new CouponDistributions());
|
|
|
|
+ });
|
|
$grid->actions(function ($actions) {
|
|
$grid->actions(function ($actions) {
|
|
$actions->disableView();
|
|
$actions->disableView();
|
|
$actions->add(new CouponDetails());
|
|
$actions->add(new CouponDetails());
|
|
- if($actions->row->position_type == 2 )
|
|
|
|
- {
|
|
|
|
- $actions->add(new CouponDistribution());
|
|
|
|
- }
|
|
|
|
});
|
|
});
|
|
|
|
|
|
$grid->column('id', __('Id'));
|
|
$grid->column('id', __('Id'));
|
|
@@ -51,9 +51,13 @@ class CouponManagementController extends AdminController
|
|
$grid->column('num', __('数量'));
|
|
$grid->column('num', __('数量'));
|
|
$grid->column('effective_days', __('有效天数'));
|
|
$grid->column('effective_days', __('有效天数'));
|
|
$grid->column('start_time', __('有效期开始时间'))->display(function ($time){
|
|
$grid->column('start_time', __('有效期开始时间'))->display(function ($time){
|
|
|
|
+ if ($time ==0)
|
|
|
|
+ return '';
|
|
return date('Y-m-d H:i:s',$time);
|
|
return date('Y-m-d H:i:s',$time);
|
|
});
|
|
});
|
|
$grid->column('end_time', __('有效期结束时间'))->display(function ($time){
|
|
$grid->column('end_time', __('有效期结束时间'))->display(function ($time){
|
|
|
|
+ if ($time ==0)
|
|
|
|
+ return '';
|
|
return date('Y-m-d H:i:s',$time);
|
|
return date('Y-m-d H:i:s',$time);
|
|
});
|
|
});
|
|
return $grid;
|
|
return $grid;
|
|
@@ -104,7 +108,7 @@ class CouponManagementController extends AdminController
|
|
$form->text('title', __('券标题'));
|
|
$form->text('title', __('券标题'));
|
|
$form->text('desc', __('使用说明'));
|
|
$form->text('desc', __('使用说明'));
|
|
$form->text('rules', __('使用规则'));
|
|
$form->text('rules', __('使用规则'));
|
|
- $form->image('icon', __('券图标'));
|
|
|
|
|
|
+ $form->image('icon', __('券图标'))->help('图标大小48px * 48px');
|
|
$form->select('type', '类型')
|
|
$form->select('type', '类型')
|
|
->options([
|
|
->options([
|
|
1 => '满减券',
|
|
1 => '满减券',
|
|
@@ -126,10 +130,8 @@ class CouponManagementController extends AdminController
|
|
])->when(1, function (Form $form) {
|
|
])->when(1, function (Form $form) {
|
|
$form->text('effective_days', __('有效天数'));
|
|
$form->text('effective_days', __('有效天数'));
|
|
})->when(2, function (Form $form) {
|
|
})->when(2, function (Form $form) {
|
|
- $form->date('start_time', __('有效期开始时间'))->required();
|
|
|
|
- $form->date('end_time', __('有效期结束时间'))->required()->rules(
|
|
|
|
- 'date|after:start_time',['after' => '结束时间小于开始时间']
|
|
|
|
- );
|
|
|
|
|
|
+ $form->date('start_time', __('有效期开始时间'));
|
|
|
|
+ $form->date('end_time', __('有效期结束时间'));
|
|
$form->saving(function ($form){
|
|
$form->saving(function ($form){
|
|
$form->start_time = strtotime($form->start_time);
|
|
$form->start_time = strtotime($form->start_time);
|
|
$form->end_time = strtotime($form->end_time);
|
|
$form->end_time = strtotime($form->end_time);
|