diff --git a/src/helpers.php b/src/helpers.php index 9963b1c48e..5ad98b0ae3 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -179,6 +179,7 @@ function backpack_user() */ function mb_ucfirst($string, $encoding = false) { + $string = $string ?? ''; $encoding = $encoding ? $encoding : mb_internal_encoding(); $strlen = mb_strlen($string, $encoding); diff --git a/src/resources/views/crud/columns/email.blade.php b/src/resources/views/crud/columns/email.blade.php index 319c50157b..5788234f9c 100644 --- a/src/resources/views/crud/columns/email.blade.php +++ b/src/resources/views/crud/columns/email.blade.php @@ -11,7 +11,7 @@ $column['text'] = '-'; if(!empty($value)) { - $column['text'] = $column['prefix'].Str::limit(strip_tags($value), $column['limit'], "[...]").$column['suffix']; + $column['text'] = $column['prefix'].Str::limit(strip_tags($value ?? ''), $column['limit'], "[...]").$column['suffix']; } @endphp diff --git a/src/resources/views/crud/columns/model_function.blade.php b/src/resources/views/crud/columns/model_function.blade.php index 1aaf440d7f..b469dc1940 100644 --- a/src/resources/views/crud/columns/model_function.blade.php +++ b/src/resources/views/crud/columns/model_function.blade.php @@ -7,7 +7,7 @@ $column['prefix'] = $column['prefix'] ?? ''; $column['suffix'] = $column['suffix'] ?? ''; $column['text'] = $column['prefix']. - Str::limit($value, $column['limit'], "[...]"). + Str::limit($value ?? '', $column['limit'], "[...]"). $column['suffix']; @endphp diff --git a/src/resources/views/crud/columns/model_function_attribute.blade.php b/src/resources/views/crud/columns/model_function_attribute.blade.php index 0a1c81bff1..9097c4009a 100644 --- a/src/resources/views/crud/columns/model_function_attribute.blade.php +++ b/src/resources/views/crud/columns/model_function_attribute.blade.php @@ -8,7 +8,7 @@ $column['prefix'] = $column['prefix'] ?? ''; $column['suffix'] = $column['suffix'] ?? ''; $column['text'] = $column['prefix']. - Str::limit($value, $column['limit'], "[...]"). + Str::limit($value ?? '', $column['limit'], "[...]"). $column['suffix']; @endphp diff --git a/src/resources/views/crud/columns/phone.blade.php b/src/resources/views/crud/columns/phone.blade.php index 0e50d36d06..798d3e6cd3 100644 --- a/src/resources/views/crud/columns/phone.blade.php +++ b/src/resources/views/crud/columns/phone.blade.php @@ -10,7 +10,7 @@ $column['text'] = ''; if(!empty($value)) { - $column['text'] = $column['prefix'].Str::limit(strip_tags($value), $column['limit'], "[...]").$column['suffix']; + $column['text'] = $column['prefix'].Str::limit(strip_tags($value ?? ''), $column['limit'], "[...]").$column['suffix']; } @endphp diff --git a/src/resources/views/crud/columns/row_number.blade.php b/src/resources/views/crud/columns/row_number.blade.php index 499ca38d87..f6746d23b9 100644 --- a/src/resources/views/crud/columns/row_number.blade.php +++ b/src/resources/views/crud/columns/row_number.blade.php @@ -5,7 +5,7 @@ $column['prefix'] = $column['prefix'] ?? ''; $column['suffix'] = $column['suffix'] ?? ''; $column['text'] = $column['prefix']. - Str::limit(strip_tags($rowNumber), $column['limit'], "[...]"). + Str::limit(strip_tags($rowNumber ?? ''), $column['limit'], "[...]"). $column['suffix']; @endphp diff --git a/src/resources/views/crud/columns/select.blade.php b/src/resources/views/crud/columns/select.blade.php index 6b51bc3fb8..9555370788 100644 --- a/src/resources/views/crud/columns/select.blade.php +++ b/src/resources/views/crud/columns/select.blade.php @@ -8,7 +8,7 @@ $attributes = $crud->getRelatedEntriesAttributes($entry, $column['entity'], $column['attribute']); foreach ($attributes as $key => &$text) { - $text = Str::limit($text, $column['limit'], '[...]'); + $text = Str::limit($text ?? '', $column['limit'], '[...]'); } @endphp diff --git a/src/resources/views/crud/columns/select_multiple.blade.php b/src/resources/views/crud/columns/select_multiple.blade.php index b639f532bc..c0d1181984 100644 --- a/src/resources/views/crud/columns/select_multiple.blade.php +++ b/src/resources/views/crud/columns/select_multiple.blade.php @@ -16,7 +16,7 @@ } foreach ($results_array as $key => $text) { - $results_array[$key] = Str::limit($text, $column['limit'], '[...]'); + $results_array[$key] = Str::limit($text ?? '', $column['limit'], '[...]'); } @endphp diff --git a/src/resources/views/crud/columns/text.blade.php b/src/resources/views/crud/columns/text.blade.php index ba3744a29b..03f29ff306 100644 --- a/src/resources/views/crud/columns/text.blade.php +++ b/src/resources/views/crud/columns/text.blade.php @@ -7,7 +7,7 @@ $column['limit'] = $column['limit'] ?? 40; $column['prefix'] = $column['prefix'] ?? ''; $column['suffix'] = $column['suffix'] ?? ''; - $column['text'] = $column['prefix'].Str::limit($value, $column['limit'], '[...]').$column['suffix']; + $column['text'] = $column['prefix'].Str::limit($value ?? '', $column['limit'], '[...]').$column['suffix']; @endphp