| xqd
@@ -19,39 +19,22 @@ class EpisodesCategoryController extends AdminController
|
|
|
protected function grid()
|
|
|
{
|
|
|
return Grid::make(new EpisodesCategory(), function (Grid $grid) {
|
|
|
+ $grid->model()->orderByDesc('sort');
|
|
|
$grid->column('id')->sortable();
|
|
|
$grid->column('name');
|
|
|
- $grid->column('pid','父分类')->display(function () {
|
|
|
- /* @var EpisodesCategory $this*/
|
|
|
- return $this->parent ?$this->parent->name : '';
|
|
|
- });
|
|
|
- $grid->column('created_at');
|
|
|
+ $grid->column('level')->using(config('global.cat_level'));
|
|
|
+// $grid->column('pid','父分类')->display(function () {
|
|
|
+// /* @var EpisodesCategory $this*/
|
|
|
+// return $this->parent ?$this->parent->name : '';
|
|
|
+// });
|
|
|
+ $grid->column('sort')->editable();
|
|
|
+ //$grid->column('created_at');
|
|
|
|
|
|
$grid->disableRowSelector();
|
|
|
$grid->disableViewButton();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Make a show builder.
|
|
|
- *
|
|
|
- * @param mixed $id
|
|
|
- *
|
|
|
- * @return Show
|
|
|
- */
|
|
|
- protected function detail($id)
|
|
|
- {
|
|
|
- return Show::make($id, new EpisodesCategory(), function (Show $show) {
|
|
|
- $show->field('id');
|
|
|
- $show->field('name');
|
|
|
- $show->field('pid');
|
|
|
- $show->field('path');
|
|
|
- $show->field('sort');
|
|
|
- $show->field('created_at');
|
|
|
- $show->field('updated_at');
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Make a form builder.
|
|
|
*
|
| xqd
@@ -60,13 +43,21 @@ class EpisodesCategoryController extends AdminController
|
|
|
protected function form()
|
|
|
{
|
|
|
return Form::make(new EpisodesCategory(), function (Form $form) {
|
|
|
- $categoryModel = app(\App\Models\EpisodesCategory::class);
|
|
|
- $options = $categoryModel::select(['id','name'])->where('pid',0)->get()->toArray();
|
|
|
- array_unshift($options,['id' => 0, 'name' => '一级分类']);
|
|
|
- $options = array_column($options,'name','id');
|
|
|
+
|
|
|
$form->display('id');
|
|
|
- $form->select('pid')->options($options);
|
|
|
- $form->text('name');
|
|
|
+ $form->radio('level')
|
|
|
+ ->when(2, function (Form $form){
|
|
|
+ $options = EpisodesCategory::select(['id','name'])
|
|
|
+ ->where('pid',0)
|
|
|
+ ->get()
|
|
|
+ ->pluck('name', 'id');
|
|
|
+ $form->select('pid')->options($options);
|
|
|
+ })
|
|
|
+ ->options(config('global.cat_level'))
|
|
|
+ ->default(1);
|
|
|
+
|
|
|
+ $form->text('name')->required();
|
|
|
+ $form->number('sort');
|
|
|
|
|
|
$form->disableViewButton();
|
|
|
$form->disableDeleteButton();
|
| xqd
@@ -76,11 +67,4 @@ class EpisodesCategoryController extends AdminController
|
|
|
$form->disableCreatingCheck();
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- public function options(Request $request)
|
|
|
- {
|
|
|
- $q = $request->get('q');
|
|
|
- $categoryModel = app(\App\Models\EpisodesCategory::class);
|
|
|
- return $categoryModel->where('name', 'like', "%$q%")->paginate(null, ['id', 'name as text']);
|
|
|
- }
|
|
|
}
|