13 changed files with 306 additions and 176 deletions
-
107app/Admin/Controllers/v3/BannerController.php
-
120app/Admin/Controllers/v3/BannersController.php
-
83app/Admin/Controllers/v3/GoodsController.php
-
90app/Admin/Controllers/v3/StoreController.php
-
4app/Admin/Repositories/v3/Banners.php
-
2app/Admin/routes.php
-
26app/Models/v3/Banners.php
-
16app/Models/v3/Goods.php
-
2app/Models/v3/GoodsBanners.php
-
18app/Models/v3/Store.php
-
10resources/lang/zh-CN/banners.php
-
2resources/lang/zh-CN/goods.php
-
2resources/lang/zh-CN/store.php
@ -1,107 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Controllers\v3; |
|||
|
|||
use App\Admin\Repositories\v3\Banner; |
|||
use Dcat\Admin\Form; |
|||
use Dcat\Admin\Grid; |
|||
use Dcat\Admin\Show; |
|||
use Dcat\Admin\Controllers\AdminController; |
|||
use App\Models\ImsCjdcMarket as MarketModel; |
|||
use App\Models\v3\Banner as BannerModel; |
|||
|
|||
class BannerController extends AdminController |
|||
{ |
|||
/** |
|||
* Make a grid builder. |
|||
* |
|||
* @return Grid |
|||
*/ |
|||
protected function grid() |
|||
{ |
|||
return Grid::make(new Banner(), function (Grid $grid) { |
|||
$grid->column('id')->sortable(); |
|||
$grid->column('market_id')->display(function($markerId){ |
|||
$market = MarketModel::getMarketInfo($markerId,'name'); |
|||
return empty($market) ? '' : $market['name']; |
|||
}); |
|||
$grid->column('title'); |
|||
$grid->column('cover_url')->image(50); |
|||
$grid->column('cover_type')->display(function($coverType){ |
|||
return isset(BannerModel::$_coverType[$coverType]) ? BannerModel::$_coverType[$coverType] : ''; |
|||
}); |
|||
$grid->column('path'); |
|||
$grid->column('path_type')->display(function($pathType){ |
|||
return isset(BannerModel::$_pathType[$pathType]) ? BannerModel::$_pathType[$pathType] : ''; |
|||
}); |
|||
$grid->column('type')->display(function($type){ |
|||
return isset(BannerModel::$_type[$type]) ? BannerModel::$_type[$type] : ''; |
|||
}); |
|||
$grid->column('sort')->sortable(); |
|||
$grid->column('status')->switch(); |
|||
// ->using(BannerModel::$_status)->label(['default' => 'primary',1 => 'primary', 0 => 'danger']);
|
|||
|
|||
$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 Banner(), function (Show $show) { |
|||
$show->field('id'); |
|||
$show->field('market_id'); |
|||
$show->field('title'); |
|||
$show->field('sub_title'); |
|||
$show->field('cover'); |
|||
$show->field('cover_type'); |
|||
$show->field('path'); |
|||
$show->field('path_type'); |
|||
$show->field('sort'); |
|||
$show->field('status'); |
|||
$show->field('type'); |
|||
$show->field('created_at'); |
|||
$show->field('updated_at'); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a form builder. |
|||
* |
|||
* @return Form |
|||
*/ |
|||
protected function form() |
|||
{ |
|||
return Form::make(new Banner(), function (Form $form) { |
|||
$form->hidden('id'); |
|||
// 市场
|
|||
$marketList = MarketModel::getMarket(); |
|||
$form->select('market_id')->width(4)->options($marketList)->default(0); |
|||
// 多个市场
|
|||
$form->multipleSelect('market_ids')->options($marketList); |
|||
$form->select('type')->options(BannerModel::$_type)->required(); |
|||
$form->text('title')->required(); |
|||
$form->text('sub_title'); |
|||
$form->image('cover')->width(2)->required(); |
|||
$form->select('cover_type')->options(BannerModel::$_coverType)->required(); |
|||
$form->text('path')->default(''); |
|||
$form->select('path_type')->options(BannerModel::$_pathType)->default(''); |
|||
$form->number('sort')->width(2)->default(0); |
|||
|
|||
|
|||
$form->disableResetButton(); |
|||
$form->disableViewCheck(); |
|||
$form->disableEditingCheck(); |
|||
$form->disableCreatingCheck(); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,120 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Controllers\v3; |
|||
|
|||
use App\Admin\Repositories\v3\Banners; |
|||
use Dcat\Admin\Form; |
|||
use Dcat\Admin\Grid; |
|||
use Dcat\Admin\Show; |
|||
use Dcat\Admin\Controllers\AdminController; |
|||
use App\Models\ImsCjdcMarket as MarketModel; |
|||
use App\Models\v3\Banners as BannersModel; |
|||
|
|||
class BannersController extends AdminController |
|||
{ |
|||
/** |
|||
* Make a grid builder. |
|||
* |
|||
* @return Grid |
|||
*/ |
|||
protected function grid() |
|||
{ |
|||
return Grid::make(new Banners(), function (Grid $grid) { |
|||
$grid->column('id')->sortable(); |
|||
$grid->column('market_id')->display(function($markerId){ |
|||
$market = MarketModel::getMarketInfo($markerId,'name'); |
|||
return empty($market) ? '' : $market['name']; |
|||
}); |
|||
$grid->column('title'); |
|||
$grid->column('cover_url')->image(50); |
|||
$grid->column('cover_type_text'); |
|||
$grid->column('path'); |
|||
$grid->column('path_type_text'); |
|||
$grid->column('type_text'); |
|||
$grid->column('sort')->sortable(); |
|||
$grid->column('status')->switch(); |
|||
// ->using(BannersModel::$_status)->label(['default' => 'primary',1 => 'primary', 0 => 'danger']);
|
|||
$grid->model()->orderby('id','desc'); |
|||
$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 Banners(), function (Show $show) { |
|||
|
|||
$show->row(function (Show\Row $show) { |
|||
$show->width(6)->field('id'); |
|||
$show->width(6)->field('market_id')->as(function ($marketId){ |
|||
$market = MarketModel::getMarketInfo($marketId,'name'); |
|||
return empty($market) ? '' : $market->name; |
|||
}); |
|||
$show->width(6)->field('title'); |
|||
$show->width(6)->field('sub_title'); |
|||
$show->width(6)->field('cover_type_text'); |
|||
$show->width(6)->field('cover')->image(); |
|||
$show->width(6)->field('type_text'); |
|||
}); |
|||
$show->row(function (Show\Row $show) { |
|||
$show->width(6)->field('path_type_text'); |
|||
$show->width(6)->field('path'); |
|||
$show->width(6)->field('status_text'); |
|||
$show->width(6)->field('sort'); |
|||
$show->width(6)->field('created_at'); |
|||
$show->width(6)->field('updated_at'); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a form builder. |
|||
* |
|||
* @return Form |
|||
*/ |
|||
protected function form() |
|||
{ |
|||
return Form::make(new Banners(), function (Form $form) { |
|||
|
|||
$form->column(6, function (Form $form) { |
|||
$form->hidden('id'); |
|||
// 市场
|
|||
$marketList = MarketModel::getMarket(); |
|||
$form->select('market_id')->options($marketList)->default(0); |
|||
// 多个市场
|
|||
$form->multipleSelect('market_ids')->options($marketList); |
|||
$form->select('type')->options(BannersModel::$_type)->required(); |
|||
$form->text('title')->required(); |
|||
$form->text('sub_title'); |
|||
$form->number('sort')->default(0); |
|||
$form->switch('status') |
|||
->customFormat(function ($v) { |
|||
return $v == '正常' ? 1 : 0; |
|||
}) |
|||
->saving(function ($v) { |
|||
return $v; |
|||
}); |
|||
}); |
|||
$form->column(6, function (Form $form) { |
|||
$form->image('cover')->required(); |
|||
$form->select('cover_type')->options(BannersModel::$_coverType)->required(); |
|||
$form->text('path')->default(''); |
|||
$form->select('path_type')->options(BannersModel::$_pathType)->default(''); |
|||
}); |
|||
|
|||
$form->disableResetButton(); |
|||
$form->disableViewCheck(); |
|||
$form->disableEditingCheck(); |
|||
$form->disableCreatingCheck(); |
|||
}); |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue