@php // Prepare data for template placeholders $templateData_prepared = [ 'name' => $resume->name, 'email' => $resume->email, 'phone' => $resume->phone ?? '', 'location' => $resume->location ?? '', 'website' => $resume->website ?? '', 'summary' => $resume->summary ?? '', 'image' => $imageData ?? '', 'experience' => $resume->experiences, 'education' => $resume->educations, 'skills' => $resume->skills, ]; @endphp @foreach($templateData['templateSections'] as $section) @php // Replace placeholders in HTML code with actual data $htmlCode = $section->html_code; // Replace simple placeholders $htmlCode = str_replace('{{name}}', $templateData_prepared['name'], $htmlCode); $htmlCode = str_replace('{{email}}', $templateData_prepared['email'], $htmlCode); $htmlCode = str_replace('{{phone}}', $templateData_prepared['phone'], $htmlCode); $htmlCode = str_replace('{{location}}', $templateData_prepared['location'], $htmlCode); $htmlCode = str_replace('{{website}}', $templateData_prepared['website'], $htmlCode); $htmlCode = str_replace('{{summary}}', $templateData_prepared['summary'], $htmlCode); $htmlCode = str_replace('{{image}}', $templateData_prepared['image'], $htmlCode); // Handle experience loop if (strpos($htmlCode, '{{#each experience}}') !== false) { $experienceHtml = ''; foreach ($resume->experiences as $experience) { $itemHtml = ''; if (strpos($htmlCode, '{{position}}') !== false) { $itemHtml = str_replace('{{position}}', $experience->position ?? '', $htmlCode); } if (strpos($htmlCode, '{{company}}') !== false) { $itemHtml = str_replace('{{company}}', $experience->company ?? '', $itemHtml); } if (strpos($htmlCode, '{{description}}') !== false) { $itemHtml = str_replace('{{description}}', $experience->description ?? '', $itemHtml); } if (strpos($htmlCode, '{{start_date}}') !== false) { $startDate = $experience->start_date ? $experience->start_date->format('M Y') : ''; $itemHtml = str_replace('{{start_date}}', $startDate, $itemHtml); } if (strpos($htmlCode, '{{end_date}}') !== false) { $endDate = $experience->end_date ? $experience->end_date->format('M Y') : 'Present'; $itemHtml = str_replace('{{end_date}}', $endDate, $itemHtml); } $experienceHtml .= $itemHtml; } $htmlCode = preg_replace('/{{#each experience}}(.*?){{\/each}}/s', $experienceHtml, $htmlCode); } // Handle education loop if (strpos($htmlCode, '{{#each education}}') !== false) { $educationHtml = ''; foreach ($resume->educations as $education) { $itemHtml = ''; if (strpos($htmlCode, '{{degree}}') !== false) { $itemHtml = str_replace('{{degree}}', $education->degree ?? '', $htmlCode); } if (strpos($htmlCode, '{{institution}}') !== false) { $itemHtml = str_replace('{{institution}}', $education->school ?? '', $itemHtml); } if (strpos($htmlCode, '{{field_of_study}}') !== false) { $itemHtml = str_replace('{{field_of_study}}', $education->field ?? '', $itemHtml); } if (strpos($htmlCode, '{{start_date}}') !== false) { $startDate = $education->start_date ? $education->start_date->format('M Y') : ''; $itemHtml = str_replace('{{start_date}}', $startDate, $itemHtml); } if (strpos($htmlCode, '{{end_date}}') !== false) { $endDate = $education->end_date ? $education->end_date->format('M Y') : 'Present'; $itemHtml = str_replace('{{end_date}}', $endDate, $itemHtml); } $educationHtml .= $itemHtml; } $htmlCode = preg_replace('/{{#each education}}(.*?){{\/each}}/s', $educationHtml, $htmlCode); } // Handle skills loop if (strpos($htmlCode, '{{#each skills}}') !== false) { $skillsHtml = ''; foreach ($resume->skills as $skill) { $itemHtml = str_replace('{{name}}', $skill->name ?? '', $htmlCode); $skillsHtml .= $itemHtml; } $htmlCode = preg_replace('/{{#each skills}}(.*?){{\/each}}/s', $skillsHtml, $htmlCode); } // Handle raw experience/education/skills (no loops) if (strpos($htmlCode, '{{{experience}}}') !== false) { $experienceHtml = ''; foreach ($resume->experiences as $experience) { $experienceHtml .= '

' . ($experience->position ?? '') . ' at ' . ($experience->company ?? '') . '

'; $experienceHtml .= '

' . ($experience->start_date ? $experience->start_date->format('M Y') : '') . ' - ' . ($experience->end_date ? $experience->end_date->format('M Y') : 'Present') . '

'; $experienceHtml .= '

' . ($experience->description ?? '') . '

'; } $htmlCode = str_replace('{{{experience}}}', $experienceHtml, $htmlCode); } if (strpos($htmlCode, '{{{education}}}') !== false) { $educationHtml = ''; foreach ($resume->educations as $education) { $educationHtml .= '

' . ($education->degree ?? '') . '

'; $educationHtml .= '

' . ($education->school ?? '') . ' (' . ($education->end_date ? $education->end_date->format('Y') : '') . ')

'; } $htmlCode = str_replace('{{{education}}}', $educationHtml, $htmlCode); } if (strpos($htmlCode, '{{{skills}}}') !== false) { $skillsHtml = ''; foreach ($resume->skills as $skill) { $skillsHtml .= '' . ($skill->name ?? '') . ''; } $htmlCode = str_replace('{{{skills}}}', $skillsHtml, $htmlCode); } @endphp {!! $htmlCode !!} @endforeach

Generated on {{ now()->format('F d, Y') }} | Resume ID: #{{ $resume->id }} | Template: {{ $templateData['template']->name }}