Skip to content

Commit 66117f1

Browse files
committed
Updated index view for category is_flat type
1 parent 40cb0a8 commit 66117f1

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

app/Grid/Admin/CategoryItemGrid.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,15 @@ public function columns()
4040
[
4141
'attribute' => 'description',
4242
'label' => __('Description'),
43+
'list' => false,
4344
],
4445
[
4546
'attribute' => 'enabled',
4647
'label' => __('Enabled'),
4748
'type' => 'checkbox',
49+
'value' => function ($model) {
50+
return $model->enabled ? 'Yes' : 'No';
51+
},
4852
'form_options' => function ($model) {
4953
return [
5054
'value' => 1,
@@ -70,6 +74,7 @@ public function columns()
7074
],
7175
];
7276
},
77+
'list' => false,
7378
],
7479
[
7580
'attribute' => 'weight',
@@ -80,15 +85,18 @@ public function columns()
8085
'wrapper' => ['class' => 'form-control py-2 w-40'],
8186
];
8287
},
88+
'list' => false,
8389
],
8490
include 'includes/tags.php',
8591
[
8692
'attribute' => 'created_at',
8793
'sortable' => true,
94+
'list' => false,
8895
],
8996
[
9097
'attribute' => 'updated_at',
9198
'sortable' => true,
99+
'list' => false,
92100
],
93101
];
94102
}

app/Http/Controllers/Admin/CategoryController.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ public function index(CategoryType $type)
2424
return $this->autocomplete($type);
2525
}
2626
$this->authorize('adminViewAny', Category::class);
27+
28+
if ($type->is_flat) {
29+
$categories = (new Category)->newQuery()->whereRelation('categoryType', 'id', $type->id);
30+
$crud = (new CategoryItemGrid);
31+
$crud->setAddtional(['type' => $type]);
32+
$crud = $crud->list($categories);
33+
return view('admin.crud.index', compact('crud'));
34+
}
2735
$items = (new Category)->toTree($type->id, true);
2836

2937
return view('admin.category.item.index', compact('items', 'type'));

0 commit comments

Comments
 (0)