Skip to content

Commit 46b2fa3

Browse files
authored
Merge pull request #92 from balajidharma/2.x-Changes
Added Filter
2 parents ec4510b + db5d9c8 commit 46b2fa3

File tree

11 files changed

+49
-15
lines changed

11 files changed

+49
-15
lines changed

app/Grid/Admin/CategoryTypeGrid.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public function columns()
2323
'label' => __('ID'),
2424
'sortable' => true,
2525
'searchable' => true,
26+
'filter' => '=',
2627
'form_options' => function ($model) {
2728
return [
2829
'hide' => true,
@@ -77,6 +78,7 @@ public function columns()
7778
'label' => __('Use Flat Category'),
7879
'sortable' => true,
7980
'searchable' => true,
81+
'filter' => '=',
8082
'type' => 'checkbox',
8183
'value' => function ($model) {
8284
return $model->is_flat ? __('Yes') : __('No');
@@ -91,7 +93,10 @@ public function columns()
9193
GridHelper::getTagsField('admin_tags', config('admin.tag_name')),
9294
[
9395
'attribute' => 'created_at',
96+
'label' => __('Created At'),
9497
'sortable' => true,
98+
'filter' => 'between',
99+
'fillable' => false
95100
],
96101
[
97102
'attribute' => 'updated_at',

app/Grid/Admin/CommentGrid.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@ class CommentGrid extends CrudBuilder
1818

1919
public function columns()
2020
{
21+
$statusOptions = [];
22+
foreach (config('comment.status') as $key => $value) {
23+
$statusOptions[$value] = __($key);
24+
};
25+
2126
return [
2227
[
2328
'attribute' => 'id',
2429
'label' => __('ID'),
2530
'sortable' => true,
2631
'searchable' => true,
32+
'filter' => '=',
2733
'list' => [
2834
'class' => 'BalajiDharma\LaravelCrud\Column\LinkColumn',
2935
'route' => 'admin.comment.show',
@@ -35,6 +41,7 @@ public function columns()
3541
'attribute' => 'content',
3642
'label' => __('Content'),
3743
'searchable' => true,
44+
'filter' => 'like',
3845
'list' => [
3946
'class' => 'BalajiDharma\LaravelCrud\Column\LinkColumn',
4047
'route' => 'admin.comment.show',
@@ -120,17 +127,14 @@ public function columns()
120127
'attribute' => 'status',
121128
'label' => __('Status'),
122129
'type' => 'select',
130+
'filter' => '=',
131+
'filter_options' => $statusOptions,
123132
'value' => function ($model) {
124133
return __(array_flip(config('comment.status'))[$model->status]);
125134
},
126-
'form_options' => function ($model) {
127-
$status = [];
128-
foreach (config('comment.status') as $key => $value) {
129-
$status[$value] = __($key);
130-
};
131-
135+
'form_options' => function ($model) use ($statusOptions) {
132136
return [
133-
'choices' => $status,
137+
'choices' => $statusOptions,
134138
'default_value' => $model ? $model->status : null,
135139
];
136140
},

app/Grid/Admin/MediaGrid.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ public function columns()
3535
];
3636
},
3737
],
38+
[
39+
'attribute' => 'variant_name',
40+
'label' => __('Type'),
41+
'type' => 'select',
42+
'filter' => '=',
43+
'filter_options' => media_type_as_options(),
44+
'list' => false,
45+
'show' => false
46+
],
3847
[
3948
'attribute' => 'filename',
4049
'fillable' => true,

app/Grid/Admin/MenuGrid.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public function columns()
2323
'label' => __('ID'),
2424
'sortable' => true,
2525
'searchable' => true,
26+
'filter' => true,
2627
'form_options' => function ($model) {
2728
return [
2829
'hide' => true,

app/Grid/Admin/PermissionGrid.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public function columns()
3131
'label' => __('ID'),
3232
'sortable' => true,
3333
'searchable' => true,
34+
'filter' => '=',
3435
'list' => [
3536
'class' => 'BalajiDharma\LaravelCrud\Column\LinkColumn',
3637
'route' => 'admin.permission.show',

app/Grid/Admin/RoleGrid.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function columns()
2424
'label' => __('ID'),
2525
'sortable' => true,
2626
'searchable' => true,
27+
'filter' => '=',
2728
'list' => [
2829
'class' => 'BalajiDharma\LaravelCrud\Column\LinkColumn',
2930
'route' => 'admin.role.show',

app/Grid/Admin/ThreadGrid.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@ class ThreadGrid extends CrudBuilder
1919

2020
public function columns()
2121
{
22+
$type = CategoryType::where('machine_name', config('forum.category_name'))->first();
23+
$categories = $type ? Category::selectOptions($type->id) : [];
2224
return [
2325
[
2426
'attribute' => 'id',
2527
'label' => __('ID'),
2628
'sortable' => true,
2729
'searchable' => true,
30+
'filter' => '=',
2831
'list' => [
2932
'class' => 'BalajiDharma\LaravelCrud\Column\LinkColumn',
3033
'route' => 'admin.thread.show',
@@ -37,12 +40,15 @@ public function columns()
3740
'label' => __('Category'),
3841
'type' => 'select',
3942
'fillable' => true,
43+
'sortable' => true,
44+
'filter' => '=',
45+
'filter_options' => $categories,
46+
'relation' => 'modelCategories',
47+
'relation_field' => 'id',
4048
'value' => function ($model) {
4149
return $model ? optional($model->getCategoriesByType(config('forum.category_name'))->first())->name : null;
4250
},
43-
'form_options' => function ($model) {
44-
$type = CategoryType::where('machine_name', config('forum.category_name'))->first();
45-
$categories = $type ? Category::selectOptions($type->id) : [];
51+
'form_options' => function ($model) use ($categories) {
4652
return [
4753
'choices' => $categories,
4854
'empty_value' => __('Select an option'),
@@ -78,6 +84,7 @@ public function columns()
7884
[
7985
'attribute' => 'content',
8086
'label' => __('Content'),
87+
'filter' => 'like',
8188
'form_options' => function ($model) {
8289
return [
8390
'field_type' => 'textarea',

app/Grid/Admin/UserGrid.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function columns()
2424
'label' => __('ID'),
2525
'sortable' => true,
2626
'searchable' => true,
27+
'filter' => '=',
2728
'list' => [
2829
'class' => 'BalajiDharma\LaravelCrud\Column\LinkColumn',
2930
'route' => 'admin.user.show',
@@ -47,6 +48,7 @@ public function columns()
4748
[
4849
'attribute' => 'email',
4950
'label' => __('Email'),
51+
'filter' => 'like',
5052
'sortable' => true,
5153
'searchable' => true,
5254
],

app/Http/Controllers/Admin/PermissionController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ public function index()
2222
$this->authorize('adminViewAny', Permission::class);
2323
$permissions = (new Permission)->newQuery();
2424

25-
$crud = (new PermissionGrid)->list($permissions);
25+
$crud = (new PermissionGrid)
26+
->setDisplaySearch(true)
27+
->setDisplayFilters(false)
28+
->list($permissions);
2629

2730
return view('admin.crud.index', compact('crud'));
2831
}

config/mediable.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
return [
4+
'model' => BalajiDharma\LaravelMediaManager\Models\Media::class,
5+
];

0 commit comments

Comments
 (0)