Skip to content

Commit 44cfa0f

Browse files
authored
Merge pull request #90 from balajidharma/2.x-Changes
Added admin tag on all the CRUD
2 parents 8738d7e + 40cb0a8 commit 44cfa0f

32 files changed

+293
-114
lines changed

app/Grid/Admin/CategoryItemGrid.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace App\Grid\Admin;
44

5-
use BalajiDharma\LaravelCrud\CrudBuilder;
65
use BalajiDharma\LaravelCategory\Models\Category;
6+
use BalajiDharma\LaravelCrud\CrudBuilder;
77

88
class CategoryItemGrid extends CrudBuilder
99
{
@@ -58,6 +58,7 @@ public function columns()
5858
'type' => 'choice',
5959
'form_options' => function ($model) {
6060
$item_options = Category::selectOptions($this->addtional['type']->id, null, true);
61+
6162
return [
6263
'choices' => $item_options,
6364
'label' => __('Parent Item'),
@@ -77,24 +78,24 @@ public function columns()
7778
'form_options' => function ($model) {
7879
return [
7980
'wrapper' => ['class' => 'form-control py-2 w-40'],
80-
'hide' => $this->addtional['type']->is_flat ? true : false,
8181
];
8282
},
8383
],
84+
include 'includes/tags.php',
8485
[
8586
'attribute' => 'created_at',
86-
'sortable' => true
87+
'sortable' => true,
8788
],
8889
[
8990
'attribute' => 'updated_at',
90-
'sortable' => true
91-
]
91+
'sortable' => true,
92+
],
9293
];
9394
}
9495

9596
public function buildRoutes($mainRoute = null)
9697
{
97-
if(!$mainRoute){
98+
if (! $mainRoute) {
9899
$routeName = request()->route()->getName();
99100
$mainRoute = substr($routeName, 0, strrpos($routeName, '.'));
100101
}
@@ -117,4 +118,4 @@ public function buildRoutes($mainRoute = null)
117118
},
118119
];
119120
}
120-
}
121+
}

app/Grid/Admin/CategoryTypeGrid.php

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace App\Grid\Admin;
44

5-
use BalajiDharma\LaravelCrud\CrudBuilder;
65
use BalajiDharma\LaravelCategory\Models\CategoryType;
6+
use BalajiDharma\LaravelCrud\CrudBuilder;
77

88
class CategoryTypeGrid extends CrudBuilder
99
{
@@ -23,11 +23,11 @@ public function columns()
2323
'label' => __('ID'),
2424
'sortable' => true,
2525
'searchable' => true,
26-
'form_options' => function($model) {
26+
'form_options' => function ($model) {
2727
return [
28-
'hide' => true
28+
'hide' => true,
2929
];
30-
}
30+
},
3131
],
3232
[
3333
'attribute' => 'name',
@@ -42,17 +42,17 @@ public function columns()
4242
'sortable' => true,
4343
'filter' => 'like',
4444
'searchable' => true,
45-
'form_options' => function($model) {
45+
'form_options' => function ($model) {
4646
return [
4747
'label' => __('Machine-readable name'),
4848
'attr' => $model->machine_name ? ['disabled' => 'disabled'] : [],
4949
];
50-
}
50+
},
5151
],
5252
[
5353
'attribute' => 'description',
5454
'label' => __('Description'),
55-
'list' => false
55+
'list' => false,
5656
],
5757
[
5858
'attribute' => 'items',
@@ -66,36 +66,37 @@ public function columns()
6666
return count($model->categories);
6767
},
6868
],
69-
'form_options' => function($model) {
69+
'form_options' => function ($model) {
7070
return [
71-
'hide' => true
71+
'hide' => true,
7272
];
73-
}
73+
},
7474
],
7575
[
7676
'attribute' => 'is_flat',
7777
'label' => __('Use Flat Category'),
7878
'sortable' => true,
7979
'searchable' => true,
8080
'type' => 'checkbox',
81-
'value' => function($model) {
81+
'value' => function ($model) {
8282
return $model->is_flat ? __('Yes') : __('No');
8383
},
84-
'form_options' => function($model) {
84+
'form_options' => function ($model) {
8585
return [
8686
'value' => 1,
8787
'checked' => $model ? $model->is_flat : false,
8888
];
89-
}
89+
},
9090
],
91+
include 'includes/tags.php',
9192
[
9293
'attribute' => 'created_at',
93-
'sortable' => true
94+
'sortable' => true,
9495
],
9596
[
9697
'attribute' => 'updated_at',
97-
'sortable' => true
98-
]
98+
'sortable' => true,
99+
],
99100
];
100101
}
101-
}
102+
}

app/Grid/Admin/MediaGrid.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace App\Grid\Admin;
44

55
use BalajiDharma\LaravelCrud\CrudBuilder;
6-
use Plank\Mediable\Media;
6+
use BalajiDharma\LaravelMediaManager\Models\Media;
77

88
class MediaGrid extends CrudBuilder
99
{
@@ -28,6 +28,7 @@ public function columns()
2828
},
2929
'form_options' => function ($model) {
3030
$type = media_type_as_options();
31+
3132
return [
3233
'choices' => $type,
3334
'default_value' => $model ? $model->variant_name : null,
@@ -46,14 +47,14 @@ public function columns()
4647
'class' => 'BalajiDharma\LaravelCrud\Column\LinkColumn',
4748
'route' => 'admin.media.show',
4849
'route_params' => ['medium' => 'id'],
49-
'attr' => ['class' => 'link link-primary']
50+
'attr' => ['class' => 'link link-primary'],
5051
],
5152
'form_options' => function ($model) {
5253
return [
5354
'attribute' => 'name',
5455
'default_value' => $model ? $model->filename : null,
5556
];
56-
}
57+
},
5758
],
5859
[
5960
'attribute' => 'alt',
@@ -68,22 +69,24 @@ public function columns()
6869
'fillable' => true,
6970
'type' => 'file',
7071
'value' => function ($model) {
71-
if($model->aggregate_type != 'image'){
72+
if ($model->aggregate_type != 'image') {
7273
$file = media_type_icon($model);
7374
} else {
7475
$file = '<image src="'.$model->getUrl().'" alt="'.$model->alt.'">';
7576
}
77+
7678
return '<div class="avatar"><div class="w-32 rounded">'.$file.'</div><div>';
7779
},
7880
],
81+
include 'includes/tags.php',
7982
[
8083
'attribute' => 'created_at',
81-
'sortable' => true
84+
'sortable' => true,
8285
],
8386
[
8487
'attribute' => 'updated_at',
85-
'sortable' => true
86-
]
88+
'sortable' => true,
89+
],
8790
];
8891
}
89-
}
92+
}

app/Grid/Admin/MenuGrid.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ public function columns()
2323
'label' => __('ID'),
2424
'sortable' => true,
2525
'searchable' => true,
26-
'form_options' => function($model) {
26+
'form_options' => function ($model) {
2727
return [
28-
'hide' => true
28+
'hide' => true,
2929
];
30-
}
30+
},
3131
],
3232
[
3333
'attribute' => 'name',
@@ -42,17 +42,17 @@ public function columns()
4242
'sortable' => true,
4343
'filter' => 'like',
4444
'searchable' => true,
45-
'form_options' => function($model) {
45+
'form_options' => function ($model) {
4646
return [
4747
'label' => __('Machine-readable name'),
4848
'attr' => $model->machine_name ? ['disabled' => 'disabled'] : [],
4949
];
50-
}
50+
},
5151
],
5252
[
5353
'attribute' => 'description',
5454
'label' => __('Description'),
55-
'list' => false
55+
'list' => false,
5656
],
5757
[
5858
'attribute' => 'items',
@@ -66,20 +66,21 @@ public function columns()
6666
return count($model->menuItems);
6767
},
6868
],
69-
'form_options' => function($model) {
69+
'form_options' => function ($model) {
7070
return [
71-
'hide' => true
71+
'hide' => true,
7272
];
73-
}
73+
},
7474
],
75+
include 'includes/tags.php',
7576
[
7677
'attribute' => 'created_at',
77-
'sortable' => true
78+
'sortable' => true,
7879
],
7980
[
8081
'attribute' => 'updated_at',
81-
'sortable' => true
82-
]
82+
'sortable' => true,
83+
],
8384
];
8485
}
85-
}
86+
}

app/Grid/Admin/MenuItemGrid.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public function columns()
5858
'type' => 'choice',
5959
'form_options' => function ($model) {
6060
$item_options = MenuItem::selectOptions($this->addtional['menu']->id, null, true);
61+
6162
return [
6263
'choices' => $item_options,
6364
'selected' => $this->model->parent_id ?? null,
@@ -102,6 +103,7 @@ public function columns()
102103
if ($model) {
103104
$itemHasRoles = array_column(json_decode($model->roles, true), 'name');
104105
}
106+
105107
return [
106108
'choices' => $roles->pluck('name', 'name')->toArray(),
107109
'choice_options' => [
@@ -115,20 +117,21 @@ public function columns()
115117
];
116118
},
117119
],
120+
include 'includes/tags.php',
118121
[
119122
'attribute' => 'created_at',
120-
'sortable' => true
123+
'sortable' => true,
121124
],
122125
[
123126
'attribute' => 'updated_at',
124-
'sortable' => true
125-
]
127+
'sortable' => true,
128+
],
126129
];
127130
}
128131

129132
public function buildRoutes($mainRoute = null)
130133
{
131-
if(!$mainRoute){
134+
if (! $mainRoute) {
132135
$routeName = request()->route()->getName();
133136
$mainRoute = substr($routeName, 0, strrpos($routeName, '.'));
134137
}
@@ -151,4 +154,4 @@ public function buildRoutes($mainRoute = null)
151154
},
152155
];
153156
}
154-
}
157+
}

app/Grid/Admin/PermissionGrid.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace App\Grid\Admin;
44

5-
use BalajiDharma\LaravelCrud\CrudBuilder;
65
use App\Models\Permission;
6+
use BalajiDharma\LaravelCrud\CrudBuilder;
77

88
class PermissionGrid extends CrudBuilder
99
{
@@ -24,7 +24,7 @@ public function columns()
2424
'list' => [
2525
'class' => 'BalajiDharma\LaravelCrud\Column\SerialColumn',
2626
],
27-
'show' => false
27+
'show' => false,
2828
],
2929
[
3030
'attribute' => 'id',
@@ -35,8 +35,8 @@ public function columns()
3535
'class' => 'BalajiDharma\LaravelCrud\Column\LinkColumn',
3636
'route' => 'admin.permission.show',
3737
'route_params' => ['permission' => 'id'],
38-
'attr' => ['class' => 'link link-primary']
39-
]
38+
'attr' => ['class' => 'link link-primary'],
39+
],
4040
],
4141
[
4242
'attribute' => 'name',
@@ -48,17 +48,18 @@ public function columns()
4848
'class' => 'BalajiDharma\LaravelCrud\Column\LinkColumn',
4949
'route' => 'admin.permission.show',
5050
'route_params' => ['permission' => 'id'],
51-
'attr' => ['class' => 'link link-primary']
52-
]
51+
'attr' => ['class' => 'link link-primary'],
52+
],
5353
],
54+
include 'includes/tags.php',
5455
[
5556
'attribute' => 'created_at',
56-
'sortable' => true
57+
'sortable' => true,
5758
],
5859
[
5960
'attribute' => 'updated_at',
60-
'sortable' => true
61-
]
61+
'sortable' => true,
62+
],
6263
];
6364
}
64-
}
65+
}

0 commit comments

Comments
 (0)