Skip to content

Commit 5d2a98b

Browse files
committed
fix Type Column if the type value is null
1 parent 6455098 commit 5d2a98b

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

resources/lang/ar/messages.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
return [
44
'title' => 'الانواع',
55
'create' => 'إنشاء نوع',
6+
'empty' => 'غير محدد',
67
'form' => [
78
'image' => 'صورة',
89
'parent_id' => 'الاب',

resources/lang/en/messages.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
return [
44
'title' => 'Types',
55
'create' => 'Create Type',
6+
'empty' => 'Not Selected',
67
'form' => [
78
'image' => 'Image',
89
'parent_id' => 'Parent',

resources/views/columns/type-column.blade.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,26 @@
5151
}
5252
5353
$arrayState = \Illuminate\Support\Arr::wrap($arrayState);
54-
$type = \TomatoPHP\FilamentTypes\Models\Type::where('key', $arrayState[0])->first();
55-
if($type){
56-
$arrayState[0] = $type->name;
54+
if(count($arrayState)){
55+
$type = \TomatoPHP\FilamentTypes\Models\Type::where('key', $arrayState[0])->first();
56+
if($type){
57+
$arrayState[0] = $type->name;
5758
58-
$hex = $type->color;
59-
list($r, $g, $b) = sscanf($hex, "#%02x%02x%02x");
60-
$colorRGB= array($r, $g, $b);
59+
$hex = $type->color;
60+
list($r, $g, $b) = sscanf($hex, "#%02x%02x%02x");
61+
$colorRGB= array($r, $g, $b);
62+
}
63+
else {
64+
$arrayState[0] = $arrayState[0];
65+
$colorRGB = [0,0,0];
66+
}
6167
}
6268
else {
63-
$arrayState[0] = $arrayState[0];
69+
$arrayState[0] = trans('filament-types::messages.empty');
6470
$colorRGB = [0,0,0];
6571
}
6672
73+
6774
@endphp
6875

6976
<div

0 commit comments

Comments
 (0)