fix view to array for education and experience calon
This commit is contained in:
@@ -29,4 +29,39 @@ class Nominee extends Model
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getEducationAttribute($value)
|
||||
{
|
||||
$longString = $value;
|
||||
|
||||
// Regular expression pattern to match the delimiter followed by any character and a newline or end of string
|
||||
$pattern = "/\d+\.\s*(.+?)(?=\d+\.\s|$)/";
|
||||
|
||||
|
||||
// Tokenize the string into an array using preg_split
|
||||
$tokens = preg_split($pattern, $longString, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
// Clean up leading and trailing whitespace from each element
|
||||
$tokens = array_map('trim', $tokens);
|
||||
|
||||
return $tokens;
|
||||
}
|
||||
|
||||
public function getExperienceAttribute($value)
|
||||
{
|
||||
$longString = $value;
|
||||
|
||||
//newline
|
||||
// Regular expression pattern to match the delimiter followed by any character and a newline or end of string
|
||||
$pattern = "/\d+\.\s*(.+?)(?:\n|$)/";
|
||||
|
||||
|
||||
// Tokenize the string into an array using preg_split
|
||||
$tokens = preg_split($pattern, $longString, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
// Clean up leading and trailing whitespace from each element
|
||||
$tokens = array_map('trim', $tokens);
|
||||
|
||||
return $tokens;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user