@@ -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 },
0 commit comments