12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- namespace App\Distributor\Controllers;
- use App\Distributor\Repositories\DistAppearance;
- use App\Distributor\Actions\AppearanceEnable;
- use App\Distributor\Repositories\DistAdminDistributor;
- use App\Libraries\CommonHelper;
- use Dcat\Admin\Grid;
- use Dcat\Admin\Http\Controllers\AdminController;
- use Dcat\Admin\Layout\Content;
- class DistAppearanceController extends AdminDistController
- {
- /**
- * page index
- */
- public function index(Content $content)
- {
- return $content
- ->header(admin_trans( 'admin.site_appearance'))
- ->description('')
- ->breadcrumb(['text'=>'list','url'=>''])
- ->body($this->grid());
- }
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- $distInfo = DistAdminDistributor::getInfo();
- return Grid::make(new DistAppearance(), function (Grid $grid) use ($distInfo) {
- //指定视图,去掉删除按钮
- $grid->view('admin.grid.table');
- $grid->column('id')->display(function () {
- return $this->_index+1;
- });
- // 标题
- $grid->column('title');
- // 封面图
- $grid->column('cover_image')->display(function ($image) {
- $dataImages = [$image];
- return CommonHelper::displayImage($dataImages,100);
- })->width('20%');
- $grid->column('describe')->width('40%');
- $grid->column('isEnabled')->display(function () use ($distInfo) {
- if ($this->id == $distInfo->appearance_id) {
- return '<span class="label" style="background:#21b978;">'.admin_trans_label('Yes').'</span>';
- } else {
- return '<span class="label" style="background:#d2d6de;">'.admin_trans_label('No').'</span>';
- }
- });
- //按钮
- $grid->disableCreateButton();
- $grid->disableDeleteButton();
- $grid->disableBatchDelete();
- $grid->tools('<a href="'.getDistributorDomain().'" target="_blank"><button class="btn btn-primary grid-refresh btn-mini" style="margin-right:3px"><i class="feather icon-chrome"></i><span class="d-none d-sm-inline"> '.admin_trans_label('browse').'</span></button></a>');
- // 操作
- $grid->actions(function (Grid\Displayers\Actions $actions) {
- $actions->disableDelete();
- $actions->disableEdit();
- $actions->disableView();
- $actions->append(new AppearanceEnable());
- });
- //排序
- $grid->model()->where('enabled',1)->orderBy('order','desc')->orderBy('id','desc');
- });
- }
- }
|