Skip to content

Commit 9d669d2

Browse files
authored
Merge pull request #88 from balajidharma/2.x-Changes
2.x changes
2 parents 09e4e01 + 9c00b55 commit 9d669d2

File tree

8 files changed

+42
-67
lines changed

8 files changed

+42
-67
lines changed

app/Grid/Admin/CategoryItemGrid.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,17 @@ public function columns()
2020
return [
2121
[
2222
'attribute' => 'name',
23-
'label' => 'Name',
23+
'label' => __('Name'),
2424
'sortable' => true,
2525
'filter' => 'like',
2626
'searchable' => true,
2727
],
2828
[
2929
'attribute' => 'slug',
3030
'label' => __('Slug'),
31+
'type' => 'text',
3132
'form_options' => function ($model) {
3233
return [
33-
'type' => 'text',
34-
'label' => __('Slug'),
3534
'help_block' => [
3635
'text' => 'The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.',
3736
],
@@ -44,11 +43,10 @@ public function columns()
4443
],
4544
[
4645
'attribute' => 'enabled',
47-
'label' => 'Enabled',
46+
'label' => __('Enabled'),
47+
'type' => 'checkbox',
4848
'form_options' => function ($model) {
4949
return [
50-
'type' => 'checkbox',
51-
'label' => __('Enabled'),
5250
'value' => 1,
5351
'default_value' => 1,
5452
];
@@ -57,10 +55,10 @@ public function columns()
5755
[
5856
'attribute' => 'parent_id',
5957
'label' => __('Parent Item'),
58+
'type' => 'choice',
6059
'form_options' => function ($model) {
6160
$item_options = Category::selectOptions($this->addtional['type']->id, null, true);
6261
return [
63-
'type' => 'choice',
6462
'choices' => $item_options,
6563
'label' => __('Parent Item'),
6664
'selected' => $this->model->parent_id ?? null,
@@ -75,11 +73,10 @@ public function columns()
7573
[
7674
'attribute' => 'weight',
7775
'label' => __('Weight'),
76+
'type' => 'number',
7877
'form_options' => function ($model) {
7978
return [
80-
'type' => 'number',
8179
'wrapper' => ['class' => 'form-control py-2 w-40'],
82-
'label' => __('Weight'),
8380
'hide' => $this->addtional['type']->is_flat ? true : false,
8481
];
8582
},

app/Grid/Admin/CategoryTypeGrid.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function columns()
2020
return [
2121
[
2222
'attribute' => 'id',
23-
'label' => 'ID',
23+
'label' => __('ID'),
2424
'sortable' => true,
2525
'searchable' => true,
2626
'form_options' => function($model) {
@@ -31,7 +31,7 @@ public function columns()
3131
],
3232
[
3333
'attribute' => 'name',
34-
'label' => 'Name',
34+
'label' => __('Name'),
3535
'sortable' => true,
3636
'filter' => 'like',
3737
'searchable' => true,
@@ -56,7 +56,7 @@ public function columns()
5656
],
5757
[
5858
'attribute' => 'items',
59-
'label' => '# of Items',
59+
'label' => __('# of Items'),
6060
'list' => [
6161
'class' => 'BalajiDharma\LaravelCrud\Column\LinkColumn',
6262
'route' => 'admin.category.type.item.index',
@@ -72,13 +72,12 @@ public function columns()
7272
'label' => __('Use Flat Category'),
7373
'sortable' => true,
7474
'searchable' => true,
75+
'type' => 'checkbox',
7576
'value' => function($model) {
7677
return $model->is_flat ? __('Yes') : __('No');
7778
},
7879
'form_options' => function($model) {
7980
return [
80-
'type' => 'checkbox',
81-
'label' => __('Use Flat Category'),
8281
'value' => 1,
8382
'checked' => $model ? $model->is_flat : false,
8483
];

app/Grid/Admin/MediaGrid.php

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,28 @@ public function columns()
2020
return [
2121
[
2222
'attribute' => 'type',
23-
'filable' => true,
23+
'fillable' => true,
2424
'label' => __('Type'),
25+
'type' => 'select',
2526
'value' => function ($model) {
2627
return $model->variant_name;
2728
},
2829
'form_options' => function ($model) {
2930
$type = media_type_as_options();
3031
return [
31-
'type' => 'select',
3232
'choices' => $type,
33-
'label' => __('Type'),
3433
'default_value' => $model ? $model->variant_name : null,
3534
];
3635
},
3736
],
3837
[
3938
'attribute' => 'filename',
40-
'filable' => true,
41-
'label' => 'Name',
39+
'fillable' => true,
40+
'label' => __('Name'),
4241
'sortable' => true,
4342
'filter' => 'like',
4443
'searchable' => true,
44+
'type' => 'text',
4545
'list' => [
4646
'class' => 'BalajiDharma\LaravelCrud\Column\LinkColumn',
4747
'route' => 'admin.media.show',
@@ -51,28 +51,22 @@ public function columns()
5151
'form_options' => function ($model) {
5252
return [
5353
'attribute' => 'name',
54-
'type' => 'text',
55-
'label' => __('Name'),
5654
'default_value' => $model ? $model->filename : null,
5755
];
5856
}
5957
],
6058
[
6159
'attribute' => 'alt',
6260
'label' => __('Alternative Text'),
63-
'filable' => true,
61+
'fillable' => true,
6462
'list' => false,
65-
'form_options' => function ($model) {
66-
return [
67-
'type' => 'text',
68-
'label' => __('Alternative Text'),
69-
];
70-
}
63+
'type' => 'text',
7164
],
7265
[
7366
'attribute' => 'file',
7467
'label' => __('File'),
75-
'filable' => true,
68+
'fillable' => true,
69+
'type' => 'file',
7670
'value' => function ($model) {
7771
if($model->aggregate_type != 'image'){
7872
$file = media_type_icon($model);
@@ -81,11 +75,6 @@ public function columns()
8175
}
8276
return '<div class="avatar"><div class="w-32 rounded">'.$file.'</div><div>';
8377
},
84-
'form_options' => function ($model) {
85-
return [
86-
'type' => 'file',
87-
];
88-
}
8978
],
9079
[
9180
'attribute' => 'created_at',

app/Grid/Admin/MenuGrid.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function columns()
2020
return [
2121
[
2222
'attribute' => 'id',
23-
'label' => 'ID',
23+
'label' => __('ID'),
2424
'sortable' => true,
2525
'searchable' => true,
2626
'form_options' => function($model) {
@@ -31,7 +31,7 @@ public function columns()
3131
],
3232
[
3333
'attribute' => 'name',
34-
'label' => 'Name',
34+
'label' => __('Name'),
3535
'sortable' => true,
3636
'filter' => 'like',
3737
'searchable' => true,
@@ -56,7 +56,7 @@ public function columns()
5656
],
5757
[
5858
'attribute' => 'items',
59-
'label' => '# of Items',
59+
'label' => __('# of Items'),
6060
'list' => [
6161
'class' => 'BalajiDharma\LaravelCrud\Column\LinkColumn',
6262
'route' => 'admin.menu.item.index',

app/Grid/Admin/MenuItemGrid.php

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function columns()
2121
return [
2222
[
2323
'attribute' => 'name',
24-
'label' => 'Name',
24+
'label' => __('Name'),
2525
'sortable' => true,
2626
'filter' => 'like',
2727
'searchable' => true,
@@ -31,7 +31,6 @@ public function columns()
3131
'label' => __('Link'),
3232
'form_options' => function ($model) {
3333
return [
34-
'label' => __('Link'),
3534
'help_block' => [
3635
'text' => 'You can also enter an internal path such as /home or an external URL such as http://example.com. Add prefix <admin> to link for admin page. Enter <nolink> to display link text only.',
3736
],
@@ -44,11 +43,10 @@ public function columns()
4443
],
4544
[
4645
'attribute' => 'enabled',
47-
'label' => 'Enabled',
46+
'label' => __('Enabled'),
47+
'type' => 'checkbox',
4848
'form_options' => function ($model) {
4949
return [
50-
'type' => 'checkbox',
51-
'label' => __('Enabled'),
5250
'value' => 1,
5351
'default_value' => 1,
5452
];
@@ -57,12 +55,11 @@ public function columns()
5755
[
5856
'attribute' => 'parent_id',
5957
'label' => __('Parent Item'),
58+
'type' => 'choice',
6059
'form_options' => function ($model) {
6160
$item_options = MenuItem::selectOptions($this->addtional['menu']->id, null, true);
6261
return [
63-
'type' => 'choice',
6462
'choices' => $item_options,
65-
'label' => __('Parent Item'),
6663
'selected' => $this->model->parent_id ?? null,
6764
'empty_value' => '-ROOT-',
6865
'help_block' => [
@@ -74,21 +71,19 @@ public function columns()
7471
[
7572
'attribute' => 'weight',
7673
'label' => __('Weight'),
74+
'type' => 'number',
7775
'form_options' => function ($model) {
7876
return [
79-
'type' => 'number',
8077
'wrapper' => ['class' => 'form-control py-2 w-40'],
81-
'label' => __('Weight'),
8278
];
8379
},
8480
],
8581
[
8682
'attribute' => 'icon',
8783
'label' => __('Icon'),
84+
'type' => 'textarea',
8885
'form_options' => function ($model) {
8986
return [
90-
'type' => 'textarea',
91-
'label' => __('Icon'),
9287
'attr' => [
9388
'rows' => 3,
9489
'class' => 'textarea input-bordered w-full',
@@ -99,21 +94,20 @@ public function columns()
9994
[
10095
'attribute' => 'roles',
10196
'label' => __('Roles'),
102-
'filable' => true,
97+
'fillable' => true,
98+
'type' => 'choice',
10399
'form_options' => function ($model) {
104100
$roles = Role::all();
105101
$itemHasRoles = [];
106102
if ($model) {
107103
$itemHasRoles = array_column(json_decode($model->roles, true), 'name');
108104
}
109105
return [
110-
'type' => 'choice',
111106
'choices' => $roles->pluck('name', 'name')->toArray(),
112107
'choice_options' => [
113108
'wrapper' => ['class' => 'col-span-4 sm:col-span-2 md:col-span-1'],
114109
],
115110
'choices_wrapper' => ['class' => 'grid grid-cols-4 gap-4'],
116-
'label' => __('Roles'),
117111
'label_attr' => ['class' => 'inline-block text-xl sm:text-2xl font-extrabold text-slate-900 tracking-tight py-4 block sm:inline-block flex'],
118112
'selected' => $itemHasRoles,
119113
'expanded' => true,

app/Grid/Admin/PermissionGrid.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function columns()
1919
{
2020
return [
2121
[
22-
'label' => '#',
22+
'label' => __('#'),
2323
'attribute' => 'label',
2424
'list' => [
2525
'class' => 'BalajiDharma\LaravelCrud\Column\SerialColumn',
@@ -28,7 +28,7 @@ public function columns()
2828
],
2929
[
3030
'attribute' => 'id',
31-
'label' => 'ID',
31+
'label' => __('ID'),
3232
'sortable' => true,
3333
'searchable' => true,
3434
'list' => [
@@ -40,7 +40,7 @@ public function columns()
4040
],
4141
[
4242
'attribute' => 'name',
43-
'label' => 'Name',
43+
'label' => __('Name'),
4444
'sortable' => true,
4545
'filter' => 'like',
4646
'searchable' => true,

app/Grid/Admin/RoleGrid.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function columns()
2121
return [
2222
[
2323
'attribute' => 'id',
24-
'label' => 'ID',
24+
'label' => __('ID'),
2525
'sortable' => true,
2626
'searchable' => true,
2727
'list' => [
@@ -33,7 +33,7 @@ public function columns()
3333
],
3434
[
3535
'attribute' => 'name',
36-
'label' => 'Name',
36+
'label' => __('Name'),
3737
'sortable' => true,
3838
'filter' => 'like',
3939
'searchable' => true,
@@ -46,9 +46,9 @@ public function columns()
4646
],
4747
[
4848
'attribute' => 'permissions',
49-
'label' => 'Permissions',
49+
'label' => __('Permissions'),
5050
'type' => 'choice',
51-
'filable' => true,
51+
'fillable' => true,
5252
'list' => [
5353
'class' => 'BalajiDharma\LaravelCrud\Column\ListColumn',
5454
'attribute' => 'name'
@@ -75,7 +75,6 @@ public function columns()
7575
'wrapper' => ['class' => 'col-span-4 sm:col-span-2 md:col-span-1'],
7676
],
7777
'choices_wrapper' => ['class' => 'grid grid-cols-4 gap-4'],
78-
'label' => __('Permissions'),
7978
'label_attr' => ['class' => 'inline-block text-xl sm:text-2xl font-extrabold text-slate-900 tracking-tight py-4 block sm:inline-block flex'],
8079
'selected' => $roleHasPermissions,
8180
'expanded' => true,

0 commit comments

Comments
 (0)