Update (list): Fix crash on list output

This commit is contained in:
2023-08-15 19:30:09 +08:00
parent ae11f4556e
commit b6ba3d2957
6 changed files with 34 additions and 18 deletions

View File

@@ -2,6 +2,22 @@
use Illuminate\Support\Str;
if (! function_exists('str_first_sentence')) {
function str_first_sentence($str) {
// Split the string at ., !, or ?
$sentences = preg_split('/(\.|!|\?)(\s|$)/', $str, 2);
// Return the first part of the array if available
if (isset($sentences[0])) {
return trim($sentences[0]);
}
// If no sentence ending found, return the whole string
return $str;
}
}
if (! function_exists('is_empty')) {
/**
* A better function to check if a value is empty or null. Strings, arrays, and Objects are supported.