调试
This commit is contained in:
@@ -22,7 +22,7 @@ class IndexController extends AdminController
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->like('title', '文章标题');
|
||||
$filter->equal('category.id', '所属分类')->select(Category::selectOptions(function ($model) {
|
||||
$filter->equal('categories.id', '所属分类')->select(Category::selectOptions(function ($model) {
|
||||
return $model->where('status', 1)->whereIn('type', [Category::TYPE_ARTICLE, Category::TYPE_SHOW]);
|
||||
}, '所有分类'));
|
||||
});
|
||||
@@ -36,7 +36,9 @@ class IndexController extends AdminController
|
||||
|
||||
$grid->column('id', '#ID#');
|
||||
$grid->column('cover', '封面图片')->image('', 100);
|
||||
$grid->column('category.title', '所属分类');
|
||||
$grid->column('所属分类')->display(function () {
|
||||
return $this->categories()->pluck('title');
|
||||
})->label();
|
||||
$grid->column('title', '文章标题');
|
||||
$grid->column('sort', '序号');
|
||||
$grid->status('状态')->switch([
|
||||
@@ -56,19 +58,6 @@ class IndexController extends AdminController
|
||||
|
||||
$form->belongsToMany('categories', CategorySelectAble::class, __('关联分类'));
|
||||
|
||||
// $form->select('category_id', '所属分类')
|
||||
// ->options(Category::selectOptions(function ($model) {
|
||||
// return $model->whereIn('type', [Category::TYPE_ARTICLE, Category::TYPE_SHOW]);
|
||||
// }, '选择分类'))
|
||||
// ->when('in', [3, 29], function (Form $form) {
|
||||
// $form->text('working', '工龄');
|
||||
// $form->text('job', '岗位');
|
||||
// })
|
||||
// ->rules('required|min:1', [
|
||||
// 'required' => '必须选择所属分类',
|
||||
// 'min' => '必须选择所属分类',
|
||||
// ]);
|
||||
|
||||
// $form->text('keywords', '关键词')->rules('nullable');
|
||||
$form->textarea('description', '内容简介')->rules('max:350');
|
||||
$form->image('cover', '封面')
|
||||
|
||||
@@ -28,9 +28,16 @@ class CategorySelectAble extends Selectable
|
||||
|
||||
$this->column('id', 'ID');
|
||||
$this->column('title', '分类名称');
|
||||
$this->column('type', '类型')->using(Category::TYPES);
|
||||
|
||||
$this->filter(function (Filter $filter) {
|
||||
$filter->like('title', '分类名称');
|
||||
$filter->equal('parent.id', '所属分类')
|
||||
->select(Category::selectOptions(function ($model) {
|
||||
return $model->where('status', 1)
|
||||
->whereIn('type', [Category::TYPE_ARTICLE, Category::TYPE_SHOW]);
|
||||
}, '所有分类'));
|
||||
$filter->equal('type', '类型')->select(Category::TYPES);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user