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.
104 lines
3.4 KiB
104 lines
3.4 KiB
<?php
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
use App\Admin\Repositories\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\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')->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);
|
|
$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->text('sort');
|
|
|
|
|
|
$form->disableResetButton();
|
|
$form->disableViewCheck();
|
|
$form->disableEditingCheck();
|
|
$form->disableCreatingCheck();
|
|
});
|
|
}
|
|
}
|