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