123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <?php
- namespace App\Admin\Controllers\Shop;
- use App\Admin\Repositories\Shop\WxShopGoodsProduct;
- use App\Wen\Utils\Settings;
- use Dcat\Admin\Form;
- use Dcat\Admin\Grid;
- use Dcat\Admin\Show;
- use Dcat\Admin\Http\Controllers\AdminController;
- class WxShopGoodsProductController extends AdminController
- {
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- $app_coin_name = Settings::get('app_coin_name', '硬币');
- return Grid::make(new WxShopGoodsProduct(), function (Grid $grid) use ($app_coin_name){
- $grid->simplePaginate();
- $grid->model()->orderBy('id', 'desc');
- $grid->column('id')->sortable();
- $grid->column('pic');
- $grid->column('param_value');
- $grid->column('vip_price')->display(function ($v) use ($app_coin_name){
- if($this->credit_type == 1){
- return '¥'.$v;
- }else{
- return $v.$app_coin_name;
- }
- })->sortable();
- $grid->column('price')->display(function ($v) use ($app_coin_name){
- if($this->credit_type == 1){
- return '¥'.$v;
- }else{
- return $v.$app_coin_name;
- }
- })->sortable();
- $grid->column('stock');
- $grid->column('sort');
- $grid->column('goods_id');
- $grid->column('state');
- $grid->column('created_at');
- $grid->column('updated_at')->sortable();
- $grid->filter(function (Grid\Filter $filter) {
- $filter->equal('id');
- });
- });
- }
- /**
- * Make a show builder.
- *
- * @param mixed $id
- *
- * @return Show
- */
- protected function detail($id)
- {
- return Show::make($id, new WxShopGoodsProduct(), function (Show $show) {
- $show->field('id');
- $show->field('pic');
- $show->field('param_value');
- $show->field('vip_price');
- $show->field('price');
- $show->field('stock');
- $show->field('sort');
- $show->field('goods_id');
- $show->field('state');
- $show->field('created_at');
- $show->field('updated_at');
- });
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- return Form::make(new WxShopGoodsProduct(), function (Form $form) {
- $form->display('id');
- $form->text('pic');
- $form->text('param_value');
- $form->text('vip_price');
- $form->text('price');
- $form->text('stock');
- $form->text('sort');
- $form->text('goods_id');
- $form->text('state');
- $form->deleting(function (Form $form){
- global $__MINI_GLOBAL_TENANT_ID__;
- if($__MINI_GLOBAL_TENANT_ID__ > 0){
- return $form->response()->error('权限不足,不可以删除其他分站对象');
- }
- });
- });
- }
- }
|