链街Dcat后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

140 lines
4.6 KiB

<?php
namespace App\Admin\Controllers;
use App\Admin\Repositories\Coupon;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Controllers\AdminController;
use App\Models\Coupon as couponModel;
use App\Models\CouponSetting as couponSettingModel;
class CouponController extends AdminController
{
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new Coupon(), function (Grid $grid) {
$grid->id->sortable();
$grid->title;
$grid->start_time_text;
$grid->end_time_text;
$grid->full_amount;
$grid->discounts;
$grid->discount_type_text;
$grid->inventory;
$grid->inventory_use;
$grid->active_type_text;
$grid->status
->using(
config('coupon.status')
)
->label(
config('coupon.status_label')
);
// $grid->usable_start_time->display(function($time){
// return date('Y-m-d H:i:s',$time);
// });
// $grid->usable_end_time->display(function($time){
// return date('Y-m-d H:i:s',$time);
// });
$grid->filter(function (Grid\Filter $filter) {
$filter->like('name');
});
});
}
/**
* Make a show builder.
*
* @param mixed $id
*
* @return Show
*/
protected function detail($id)
{
return Show::make($id, new Coupon(), function (Show $show) {
$show->id;
$show->title;
$show->introduce;
$show->start_time;
$show->end_time;
$show->full_amount;
$show->discounts;
$show->is_new_user;
$show->inventory;
$show->inventory_use;
$show->type;
$show->market_id;
$show->storetype_id;
$show->category;
$show->active_type;
$show->status;
$show->remark;
$show->weigh;
$show->usable_number;
$show->usable_start_time;
$show->usable_end_time;
$show->discount_type;
$show->created_at;
$show->updated_at;
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
return Form::make(new Coupon(), function (Form $form) {
$form->display('id');
$form->text('title')->required()->maxLength(255,'最多只能输入500个字');
$form->textarea('introduce')->required();
$form->text('full_amount')->width(2)->required()->floatTwo();
$form->text('discounts')->width(2)->required()->floatTwo();
$form->radio('discount_type')->options(config('coupon.discount_type'))->default(1)->required();
$form->text('inventory')->width(2)->required()->type('number')->attribute('min', 1)->default(1);
$form->datetime('start_time')->width(3)->required();
$form->datetime('end_time')->width(3)->required();
$form->datetime('usable_start_time')->width(3)->required();
$form->datetime('usable_end_time')->width(3)->required();
$form->select('active_type')->width(3)->options(config('coupon.active_type'))->default(1);
/* 领取方式 */
$receive = couponSettingModel::select('id','value','name')->where('category')->get();
$form->select('receive_type')->width(3)->options([])->default(2);
$form->select('type')->width(3)->options(config('coupon.type'))->default(1)->disable();
$form->select('category')->width(3)->options(config('coupon.category'))->default(1)->disable();
/* 目前默认全平台的市场 2020-08-20*/
$form->select('market_id')->width(3)->options(['所有市场'])->disable();
/* 目前默认全平台的店铺分类 2020-08-20*/
$form->select('storetype_id')->width(3)->options(['所有店铺类型'])->disable();
$form->radio('is_new_user')->options(config('coupon.is_new_user'))->default(2)->disable();
// $form->text('usable_number')->width(2)->default(1)->disable();
$form->text('weigh')->width(2)->type('number')->attribute('min', 0)->default(0);
$form->text('remark')->maxLength(500,'最多只能输入500个字');
$form->display('created_at');
$form->display('updated_at');
});
}
}