fix view to array for education and experience calon

This commit is contained in:
nurafrinaalimi16
2024-04-28 11:48:23 +08:00
parent 194f28d584
commit aff14b29cd
2 changed files with 44 additions and 2 deletions
+35
View File
@@ -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;
}
}
@@ -93,8 +93,15 @@
<div class="detail-section">
<span><b> Nama : </b>{{ nomineeViewed.name }}</span>
<span><b> Unit : </b>{{ nomineeViewed.unit }}</span>
<span><b> Taraf Pendidikan : </b>{{ nomineeViewed.education }}</span>
<span><b> Pengalaman Kerja : </b>{{ nomineeViewed.experience }}</span>
<span> <b>Taraf Pendidikan :</b> </span>
<ol>
<li v-for="(item, index) in nomineeViewed.education" :key="index">{{ item }}</li>
</ol>
<span><b> Pengalaman Kerja : </b></span>
<ol>
<li v-for="(item, index) in nomineeViewed.experience" :key="index">{{ item }}</li>
</ol>
</div>
</div>
</div>