diff --git a/app/Exports/PresenceExport.php b/app/Exports/PresenceExport.php
new file mode 100644
index 0000000..d268d31
--- /dev/null
+++ b/app/Exports/PresenceExport.php
@@ -0,0 +1,92 @@
+userId = decrypt($request->query('user'));
+ $this->companyId = decrypt($request->query('company'));
+ }
+
+ public function collection()
+ {
+ $userId = $this->userId;
+ $companyId = $this->companyId;
+
+ // Fetch the presences based on the user_id and company_id
+ $presences = Presence::where('user_id', $userId)
+ ->where('company_id', $companyId)
+ ->orderBy('date', 'asc')
+ ->get();
+
+ return $presences->map(function ($presence) {
+ return [
+ 'Tanggal' => $presence->date,
+ 'Jam Masuk' => $presence->check_in,
+ 'Jam Keluar' => $presence->check_out,
+ 'Status' => $presence->is_approved ? 'Sudah Disetujui' : 'Belum Disetujui',
+ ];
+ });
+ }
+
+ public function headings(): array
+ {
+ return [
+ ['Nama', 'Kelas', 'Company'],
+ ['', '', ''],
+ ['Tanggal', 'Jam Masuk', 'Jam Keluar', 'Status']
+ ];
+ }
+
+ public function title(): string
+ {
+ return 'Presences Data';
+ }
+
+ public function startCell(): string
+ {
+ return 'A3';
+ }
+
+ public function styles(Worksheet $sheet)
+ {
+ $user = User::find($this->userId);
+
+ $sheet->setCellValue('A1', 'Nama: ' . $user->name);
+ $sheet->setCellValue('B1', 'Kelas: ' . ($user->courses()->first()?->name ?? 'N/A'));
+ $sheet->setCellValue('C1', 'Company: ' . $user->companies()->find($this->companyId)->name);
+
+ // Atur style untuk baris pertama
+ $sheet->getStyle('A1:C1')->applyFromArray([
+ 'font' => [
+ 'bold' => true,
+ ],
+ ]);
+
+ $sheet->getStyle('A3:D3')->applyFromArray([
+ 'font' => [
+ 'bold' => true,
+ ],
+ 'fill' => [
+ 'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
+ 'startColor' => [
+ 'argb' => 'FFD9D9D9',
+ ],
+ ],
+ ]);
+ }
+}
diff --git a/app/Http/Controllers/Api/ApplianceController.php b/app/Http/Controllers/Api/ApplianceController.php
index 0993744..a5d8d5f 100644
--- a/app/Http/Controllers/Api/ApplianceController.php
+++ b/app/Http/Controllers/Api/ApplianceController.php
@@ -121,6 +121,14 @@ public function editDate(Request $request, $id)
}
}
+ $user->presences()->where('company_id', $id)
+ ->where('date', '>', $endDate)
+ ->delete();
+
+ $user->journals()->where('company_id', $id)
+ ->where('date', '>', $endDate)
+ ->delete();
+
} catch (\Exception $e) {
return response()->json([
'message' => 'Error while updating date',
diff --git a/app/Http/Controllers/Api/ExportController.php b/app/Http/Controllers/Api/ExportController.php
index c5a361e..c644b12 100644
--- a/app/Http/Controllers/Api/ExportController.php
+++ b/app/Http/Controllers/Api/ExportController.php
@@ -11,7 +11,7 @@
class ExportController extends Controller
{
- public function exportJournal(Request $request, $id)
+ public function pdfSingleCompany(Request $request, $id)
{
$user = auth()->user();
$courseName = $user->courses->first()?->name;
@@ -31,8 +31,12 @@ public function exportJournal(Request $request, $id)
if (!$company) {
return response()->json(['error' => 'Company not found!'], 404);
}
- $companyName = $company?->name ?? 'N/A';
+ $internDate = $user->internDates()->where('company_id', $companyId)->first();
+
+ $startDate = $internDate ? Carbon::parse($internDate->start_date)->translatedFormat('j F Y') : 'N/A';
+ $endDate = $internDate ? Carbon::parse($internDate->end_date)->translatedFormat('j F Y') : 'N/A';
+
$presences = $user->presences()
->where('company_id', $companyId)
->whereDate('date', '<=', Carbon::now())
@@ -57,15 +61,35 @@ public function exportJournal(Request $request, $id)
return response()->json(['error' => 'No journals found!'], 404);
}
+ $parentAddress = $request->input('parent_address') ?? $user->address;
+ $directors = $request->input('directors', []);
+ $hrds = $request->input('hrds', []);
+ $schoolMentors = $request->input('school_mentors', []);
+ $companyMentors = $request->input('company_mentors', []);
+
$formFields = [
- 'namasiswa' => $user->name,
+ 'namasiswa' => $user->name,
'kelas' => $courseLevel,
+ 'nis' => $request->input('nis'),
+ 'nis_nisn' => $request->input('nis') . '/' . $request->input('nisn'),
+ 'gol_darah' => $request->input('blood_type'),
'alamat_siswa' => $user->address,
'jurusan' => $user->departments->first()?->description,
- 'instansi_nama' => $companyName,
'kelasjurusan' => $courseName,
'ttl' => $formattedDateOfBirth,
'gender' => $gender,
+ 'namaortu' => $request->input('parent_name'),
+ 'alamat_ortu' => $parentAddress,
+ 'tgl_export' => Carbon::now()->translatedFormat('l, j F Y'),
+ 'instansi_nama' => $company->name,
+ 'instansi_bidang' => $company->category,
+ 'instansi_alamat' => $company->address,
+ 'instansi_tglmulai' => $startDate,
+ 'instansi_tglselesai' => $endDate,
+ 'instansi_direktur' => $directors[0]['name'] ?? 'N/A',
+ 'instansi_hrd' => $hrds[0]['name'] ?? 'N/A',
+ 'instansi_psekolah' => $schoolMentors[0]['name'] ?? 'N/A',
+ 'instansi_piduka' => $companyMentors[0]['name'] ?? 'N/A',
];
foreach ($presences as $index => $presence) {
@@ -98,8 +122,119 @@ public function exportJournal(Request $request, $id)
$tempPath = storage_path('storage/journals/' . $fileName);
$outputPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $fileName;
$pdf = new Pdf($templatePath);
- $pdf->fillForm($formFields)->flatten()->saveAs($outputPath);
+ $result = $pdf->fillForm($formFields)->flatten()->saveAs($outputPath);
+ if (!$result) {
+ $error = $pdf->getError();
+ return response()->json(['error' => 'Failed to generate PDF: ' . $error], 500);
+ }
+
+ return response()->download($outputPath, $fileName)->deleteFileAfterSend(true);
+ }
+
+ public function pdfMultipleCompany(Request $request)
+ {
+ $user = auth()->user();
+ $courseName = $user->courses->first()?->name;
+ $courseLevel = $courseName ? explode(' ', $courseName)[0] : 'N/A';
+
+ $formattedDateOfBirth = $user->date_of_birth
+ ? Carbon::parse($user->date_of_birth)->translatedFormat('j F Y')
+ : 'N/A';
+
+ $gender = match ($user->gender) {
+ 'male' => 'Laki-Laki',
+ 'female' => 'Perempuan'
+ };
+
+ $parentAddress = $request->input('parent_address') ?? $user->address;
+
+ $companies = $user->companies;
+
+ if ($companies->isEmpty()) {
+ return response()->json(['error' => 'No companies associated with the user!'], 404);
+ }
+
+ $formFields = [
+ 'namasiswa' => $user->name,
+ 'kelas' => $courseLevel,
+ 'nis' => $request->input('nis'),
+ 'nis_nisn' => $request->input('nis') . '/' . $request->input('nisn'),
+ 'gol_darah' => $request->input('blood_type'),
+ 'alamat_siswa' => $user->address,
+ 'jurusan' => $user->departments->first()?->description,
+ 'kelasjurusan' => $courseName,
+ 'ttl' => $formattedDateOfBirth,
+ 'gender' => $gender,
+ 'namaortu' => $request->input('parent_name'),
+ 'alamat_ortu' => $parentAddress,
+ 'tgl_export' => Carbon::now()->translatedFormat('l, j F Y'),
+ ];
+ $directors = $request->input('directors', []);
+ $hrds = $request->input('hrds', []);
+ $school_mentors = $request->input('school_mentors', []);
+ $company_mentors = $request->input('company_mentors', []);
+
+ foreach ($companies as $index => $company) {
+ $companyIndex = $index + 1;
+
+ $formFields["instansi{$companyIndex}_nama"] = $company->name;
+ $formFields["instansi{$companyIndex}_bidang"] = $company->category;
+ $formFields["instansi{$companyIndex}_alamat"] = $company->address;
+ $formFields["instansi{$companyIndex}_hrd"] = $company->contact_person;
+ $formFields["instansi{$companyIndex}_tglmulai"] = Carbon::parse($company->internDates->first()->start_date)->translatedFormat('j F Y');
+ $formFields["instansi{$companyIndex}_tglselesai"] = Carbon::parse($company->internDates->first()->end_date)->translatedFormat('j F Y');
+ $formFields["instansi{$companyIndex}_direktur"] = $directors[$index]['name'] ?? 'N/A';
+ $formFields["instansi{$companyIndex}_hrd"] = $hrds[$index]['name'] ?? 'N/A';
+ $formFields["instansi{$companyIndex}_psekolah"] = $school_mentors[$index]['name'] ?? 'N/A';
+ $formFields["instansi{$companyIndex}_piduka"] = $company_mentors[$index]['name'] ?? 'N/A';
+
+ $presences = $user->presences()
+ ->where('company_id', $company->id)
+ ->whereDate('date', '<=', Carbon::now())
+ ->orderBy('date', 'asc')
+ ->get()
+ ->filter(fn($presence) => !is_null($presence->check_in))
+ ->values();
+
+ foreach ($presences as $presenceIndex => $presence) {
+ $formFields["{$companyIndex}_tanggal" . ($presenceIndex + 1)] = Carbon::parse($presence->date)->translatedFormat('l, j F Y');
+ $formFields["{$companyIndex}_checkin" . ($presenceIndex + 1)] = $presence->check_in;
+ $formFields["{$companyIndex}_checkout" . ($presenceIndex + 1)] = $presence->check_out ?? 'N/A';
+ }
+
+ $journals = $user->journals()
+ ->where('company_id', $company->id)
+ ->whereDate('date', '<=', Carbon::now())
+ ->orderBy('date', 'asc')
+ ->get()
+ ->filter(fn($journal) => !is_null($journal->work_type))
+ ->values();
+
+ foreach ($journals as $journalIndex => $journal) {
+ $formFields["{$companyIndex}_no" . ($journalIndex + 1)] = $journalIndex + 1;
+ $formFields["{$companyIndex}_bidang" . ($journalIndex + 1)] = $journal->work_type;
+ $formFields["{$companyIndex}_uraian" . ($journalIndex + 1)] = $journal->description;
+ $formFields["{$companyIndex}_tgl_jurnal" . ($journalIndex + 1)] = Carbon::parse($journal->date)->translatedFormat('l, j F Y');
+ }
+ }
+
+ $templatePath = public_path('template-pdf/template_2-company.pdf');
+ if (!file_exists($templatePath)) {
+ return response()->json(['error' => 'PDF template not found!'], 404);
+ }
+
+ $fileName = $user->id . time() . '.pdf';
+ $tempPath = storage_path('storage/journals/' . $fileName);
+ $outputPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $fileName;
+ $pdf = new Pdf($templatePath);
+ $result = $pdf->fillForm($formFields)->flatten()->saveAs($outputPath);
+ if (!$result) {
+ $error = $pdf->getError();
+ return response()->json(['error' => 'Failed to generate PDF: ' . $error], 500);
+ }
+
return response()->download($outputPath, $fileName)->deleteFileAfterSend(true);
}
+
}
diff --git a/app/Http/Controllers/Api/FaqController.php b/app/Http/Controllers/Api/FaqController.php
new file mode 100644
index 0000000..111e8b7
--- /dev/null
+++ b/app/Http/Controllers/Api/FaqController.php
@@ -0,0 +1,78 @@
+json([
+ 'message' => 'Error while getting FAQs',
+ 'error' => $e->getMessage(),
+ ], 500);
+ }
+
+ return response()->json([
+ 'message' => 'FAQs retrieved successfully',
+ 'faqs' => $faqs,
+ ], 200);
+ }
+
+ /**
+ * Show the form for creating a new resource.
+ */
+ public function create()
+ {
+ //
+ }
+
+ /**
+ * Store a newly created resource in storage.
+ */
+ public function store(Request $request)
+ {
+ //
+ }
+
+ /**
+ * Display the specified resource.
+ */
+ public function show(string $id)
+ {
+ //
+ }
+
+ /**
+ * Show the form for editing the specified resource.
+ */
+ public function edit(string $id)
+ {
+ //
+ }
+
+ /**
+ * Update the specified resource in storage.
+ */
+ public function update(Request $request, string $id)
+ {
+ //
+ }
+
+ /**
+ * Remove the specified resource from storage.
+ */
+ public function destroy(string $id)
+ {
+ //
+ }
+}
diff --git a/app/Http/Controllers/Api/VacancyController.php b/app/Http/Controllers/Api/VacancyController.php
index 1b6201f..0c66877 100644
--- a/app/Http/Controllers/Api/VacancyController.php
+++ b/app/Http/Controllers/Api/VacancyController.php
@@ -19,7 +19,7 @@ public function index()
try {
$vacancies = Vacancy::whereHas('company', function ($query) use ($departmentId) {
$query->where('department_id', $departmentId);
- })->orderBy('updated_at', 'desc')->get();
+ })->where('status', 1)->orderBy('updated_at', 'desc')->get();
} catch (\Exception $e) {
return response()->json([
'status' => false,
@@ -49,7 +49,7 @@ public function recommended()
$query->whereHas('company', function ($query) use ($departmentId) {
$query->where('department_id', $departmentId);
});
- })->get();
+ })->where('status', 1)->get();
$vacancies = array_merge($vacancies, $vacancy->toArray());
}
@@ -81,7 +81,7 @@ public function search($searchbar)
});
})->whereHas('company', function ($query) use ($departmentId) {
$query->where('department_id', $departmentId);
- })->orderBy('updated_at', 'desc')->get();
+ })->orderBy('updated_at', 'desc')->where('status', 1)->get();
} catch (\Exception $e) {
return response()->json([
'status' => false,
@@ -135,7 +135,7 @@ public function store(Request $request)
public function show($id)
{
try {
- $vacancy = Vacancy::findOrFail($id);
+ $vacancy = Vacancy::where('id', $id)->where('status', 1)->firstOrFail();
} catch (\Exception $e) {
return response()->json([
'status' => false,
diff --git a/app/Http/Controllers/FaqController.php b/app/Http/Controllers/FaqController.php
new file mode 100644
index 0000000..76b2357
--- /dev/null
+++ b/app/Http/Controllers/FaqController.php
@@ -0,0 +1,247 @@
+search($search);
+ })
+ ->when($status, function ($query, $status) {
+ return $query->where('status', $status);
+ })
+ ->when($sort, function ($query, $sort) {
+ if ($sort[0] == '-') {
+ $sort = substr($sort, 1);
+ $sortType = 'desc';
+ } else {
+ $sortType = 'asc';
+ }
+ return $query->orderBy($sort, $sortType);
+ })
+ ->paginate(10);
+
+ $faqs->withPath('/faqs')->withQueryString();
+
+ if ($faqs->count() > 0) {
+ $context = [
+ 'status' => true,
+ 'message' => 'Data FAQ ditemukan',
+ 'faqs' => $faqs,
+ 'pagination' => $faqs->links()->render(),
+ 'search' => $search,
+ 'statusData' => $status,
+ 'sort' => $sort,
+ ];
+ } else {
+ $context = [
+ 'status' => false,
+ 'message' => 'Data FAQ tidak ditemukan',
+ 'faqs' => [],
+ 'pagination' => $faqs->links()->render(),
+ 'search' => $search,
+ 'statusData' => $status,
+ 'sort' => $sort,
+ ];
+ }
+
+ return $context;
+ }
+
+ public function index(Request $request)
+ {
+ $search = $request->query('search');
+ $status = $request->query('status');
+ $sort = $request->query('sort');
+
+ $sort = $sort ? $sort : 'question';
+
+ $context = $this->getData($search, $status, $sort);
+
+ return view('faqs.index', $context);
+ }
+
+ /**
+ * Show the form for creating a new resource.
+ */
+ public function create()
+ {
+ return view('faqs.create');
+ }
+
+ /**
+ * Store a newly created resource in storage.
+ */
+ public function store(Request $request)
+ {
+ $request->validate([
+ 'question' => 'required|string|max:255',
+ 'answer' => 'required|string',
+ ]);
+
+ $answer = $this->saveContentImages($request->answer);
+
+ Faq::create([
+ 'question' => $request->question,
+ 'answer' => $answer,
+ ]);
+
+ return redirect()->route('faqs.index')->with('success', 'FAQ berhasil ditambahkan');
+ }
+
+ /**
+ * Display the specified resource.
+ */
+ public function show(string $id)
+ {
+ //
+ }
+
+ /**
+ * Show the form for editing the specified resource.
+ */
+ public function edit(string $id)
+ {
+ $id = decrypt($id);
+ $faq = Faq::findOrFail($id);
+ // dd($faq);
+ return view('faqs.edit', compact('faq'));
+ }
+
+ /**
+ * Update the specified resource in storage.
+ */
+ public function update(Request $request, string $id)
+ {
+ $request->validate([
+ 'question' => 'required|string|max:255',
+ 'answer' => 'required|string',
+ ]);
+
+ $faq = Faq::find(decrypt($id));
+ $oldAnswer = $faq->answer;
+
+ $answer = $this->saveContentImages($request->answer);
+ // dd($answer, $oldAnswer);
+
+ $faq->update([
+ 'question' => $request->question,
+ 'answer' => $answer
+ ]);
+
+ $this->deleteUnusedImages($oldAnswer, $answer);
+
+ return redirect()->route('faqs.index')->with('success', 'FAQ berhasil diperbarui');
+ }
+
+ /**
+ * Remove the specified resource from storage.
+ */
+ public function destroy(string $id)
+ {
+ $faq = Faq::find(decrypt($id));
+ $this->deleteImages($faq->answer);
+ $faq->delete();
+
+ return back()->with('success', 'Faq deleted successfully!');
+ }
+
+ private function saveContentImages($content)
+ {
+ $dom = new DOMDocument();
+ libxml_use_internal_errors(true);
+ $dom->loadHTML($content, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
+
+ $images = $dom->getElementsByTagName('img');
+
+ foreach ($images as $key => $img) {
+ $src = $img->getAttribute('src');
+
+ // Jika gambar adalah base64 (gambar baru diupload)
+ if (strpos($src, 'data:image') === 0) {
+ $data = base64_decode(explode(',', explode(';', $src)[1])[1]);
+ $image_name = 'uploads/' . time() . $key . '.png';
+ file_put_contents(public_path($image_name), $data);
+
+ $img->removeAttribute('src');
+ $img->setAttribute('src', env('ASSET_URL') . $image_name);
+ }
+ }
+
+ return $dom->saveHTML();
+ }
+
+
+ private function deleteUnusedImages($oldAnswer, $used_images)
+ {
+ if (!is_array($used_images)) {
+ $used_images = [$used_images];
+ }
+
+ $domain = env('ASSET_URL');
+ $dom = new DOMDocument();
+ libxml_use_internal_errors(true);
+ $dom->loadHTML($oldAnswer, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
+
+ $oldImages = $dom->getElementsByTagName('img');
+ $old_image_paths = [];
+
+ foreach ($oldImages as $img) {
+ $old_image = $img->getAttribute('src');
+ if (empty($old_image)) {
+ continue;
+ }
+ $old_image_paths[] = $old_image;
+ }
+
+ $domUsedImages = new DOMDocument();
+ $domUsedImages->loadHTML(implode("", $used_images), LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
+ $usedImagePaths = [];
+
+ $usedImages = $domUsedImages->getElementsByTagName('img');
+ foreach ($usedImages as $img) {
+ $usedImagePaths[] = $img->getAttribute('src');
+ }
+
+ foreach ($old_image_paths as $old_image) {
+ // dd(in_array($old_image, $usedImagePaths));
+ if (!in_array($old_image, $usedImagePaths)) {
+ if (strpos($old_image, $domain) === 0) {
+ $old_image = str_replace($domain, '', $old_image);
+ }
+ $old_image_path = public_path($old_image);
+
+ if (file_exists($old_image_path)) {
+ unlink($old_image_path);
+ }
+ }
+ }
+ }
+
+ private function deleteImages($answer)
+ {
+ $domain = env('ASSET_URL');
+ $dom = new DOMDocument();
+ libxml_use_internal_errors(true);
+ $dom->loadHTML($answer, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
+
+ $images = $dom->getElementsByTagName('img');
+
+ foreach ($images as $img) {
+ $src = $img->getAttribute('src');
+ $src = str_replace($domain, '', $src);
+ $image_path = public_path($src);
+
+ if (file_exists($image_path)) {
+ unlink($image_path);
+ }
+ }
+ }
+}
diff --git a/app/Http/Controllers/StudentController.php b/app/Http/Controllers/StudentController.php
index 7fb127e..dd84c27 100644
--- a/app/Http/Controllers/StudentController.php
+++ b/app/Http/Controllers/StudentController.php
@@ -11,7 +11,7 @@
class StudentController extends Controller
{
- public function getData($search=null, $status=null, $school=null, $department=null, $sort=null)
+ public function getData($search=null, $status=null, $school=null, $department=null, $sort=null, $academicYear = null)
{
$isManager = auth()->user()->hasRole('manager');
$isKaprog = auth()->user()->hasRole('kepala program');
@@ -21,6 +21,17 @@ public function getData($search=null, $status=null, $school=null, $department=nu
$users = User::whereRelation('roles', 'name', 'student')
->with(['companies', 'internDates', 'schools', 'departments']);
+ if ($academicYear) {
+ $yearRange = explode('-', $academicYear);
+ if (count($yearRange) == 2) {
+ $startYear = $yearRange[0];
+ $endYear = $yearRange[1];
+ $users = $users->whereBetween('created_at', [
+ Carbon::create($startYear, 1, 1)->startOfDay(),
+ Carbon::create($startYear, 12, 31)->endOfDay(),
+ ]);
+ }
+ }
if ($search) {
$users = $users->where('name', 'like', '%' . $search . '%')
->orWhere('email', 'like', '%' . $search . '%');
@@ -75,6 +86,7 @@ public function getData($search=null, $status=null, $school=null, $department=nu
'school' => $school,
'department' => $department,
'sort' => $sort,
+ 'academicYear' => $academicYear,
];
} else {
$context = [
@@ -87,6 +99,7 @@ public function getData($search=null, $status=null, $school=null, $department=nu
'school' => $school,
'department' => $department,
'sort' => $sort,
+ 'academicYear' => $academicYear,
];
}
@@ -105,9 +118,22 @@ public function index(Request $request)
$school = $request->query('school');
$department = $request->query('department');
$sort = $request->query('sort');
+ $academicYear = $request->query('academic_year');
+
$sort = $sort ? $sort : 'name';
- $context = $this->getData($search, $status, $school, $department, $sort);
+ $currentDate = Carbon::now();
+ $currentYear = $currentDate->year;
+
+ if ($currentDate->month >= 5 && $currentDate->month <= 12) {
+ $defaultAcademicYear = $currentYear . '-' . ($currentYear + 1);
+ } else {
+ $defaultAcademicYear = ($currentYear - 1) . '-' . $currentYear;
+ }
+
+ $academicYear = $academicYear ? $academicYear : $defaultAcademicYear;
+
+ $context = $this->getData($search, $status, $school, $department, $sort, $academicYear);
return $context['status']
? view('students.index', $context)
@@ -239,6 +265,14 @@ public function update(Request $request, $id)
]
);
+ $user->presences()->where('company_id', $companyId)
+ ->where('date', '>', $endDate)
+ ->delete();
+
+ $user->journals()->where('company_id', $companyId)
+ ->where('date', '>', $endDate)
+ ->delete();
+
$presencePending = PresenceStatus::where('name', 'Pending')->first('id')->id;
for ($i = $startDate; $i <= $endDate; $i->addDay()) {
diff --git a/app/Http/Controllers/VacancyController.php b/app/Http/Controllers/VacancyController.php
index 9680194..be4949e 100644
--- a/app/Http/Controllers/VacancyController.php
+++ b/app/Http/Controllers/VacancyController.php
@@ -27,6 +27,7 @@ private function getData($company, $search=null, $sort=null)
}
return $query->orderBy($sort, $sortType);
})
+ ->orderByDesc('status')
->paginate(10);
$vacancies->withPath('/vacancies')->withQueryString();
@@ -151,6 +152,7 @@ public function update(Request $request, $id)
'description' => 'nullable|string',
'skills' => 'required|string',
'slots' => 'required|integer',
+ 'status' => 'boolean',
]);
$vacancy = Vacancy::findOrFail($id);
diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php
index 873020f..a6ad588 100644
--- a/app/Http/Kernel.php
+++ b/app/Http/Kernel.php
@@ -56,6 +56,7 @@ class Kernel extends HttpKernel
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
+ 'auth.check_status' => \App\Http\Middleware\CheckUserStatus::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
diff --git a/app/Http/Middleware/CheckUserStatus.php b/app/Http/Middleware/CheckUserStatus.php
new file mode 100644
index 0000000..2a32ba4
--- /dev/null
+++ b/app/Http/Middleware/CheckUserStatus.php
@@ -0,0 +1,32 @@
+status != 1) {
+ $user->tokens()->delete();
+ Auth::logout();
+ return response()->json([
+ 'error' => 'Unauthorized',
+ 'message' => 'Akun anda dinonaktifkan, silakan hubungi admin',
+ ], 401);
+ }
+
+ return $next($request);
+ }
+}
diff --git a/app/Models/Faq.php b/app/Models/Faq.php
new file mode 100644
index 0000000..3d61500
--- /dev/null
+++ b/app/Models/Faq.php
@@ -0,0 +1,15 @@
+id();
+ $table->string('question');
+ $table->text('answer');
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::dropIfExists('faqs');
+ }
+};
diff --git a/database/seeders/FaqSeeder.php b/database/seeders/FaqSeeder.php
new file mode 100644
index 0000000..6674ac8
--- /dev/null
+++ b/database/seeders/FaqSeeder.php
@@ -0,0 +1,26 @@
+ 'Tidak Bisa Login',
+ 'answer' => 'Banyak pengguna mengalami masalah ini karena salah mengakses website admin, bukan website client. Pastikan Anda mengakses website yang benar untuk login ke akun client.',
+ ]);
+
+ Faq::create([
+ 'question' => 'Tidak Bisa Absen',
+ 'answer' => 'Untuk absen, pastikan Anda sudah menentukan tanggal PKL di menu intern, tab "PKL-ku". Jika sudah melewati periode PKL, lakukan hal yang sama untuk menentukan tanggal sesuai periode PKL.',
+ ]);
+ }
+}
diff --git a/database/seeders/MenuSeeder.php b/database/seeders/MenuSeeder.php
index 68f74f6..c903501 100644
--- a/database/seeders/MenuSeeder.php
+++ b/database/seeders/MenuSeeder.php
@@ -153,6 +153,15 @@ public function run()
'parent_id' => null,
'permission_id' => Permission::where('name', 'role-list')->first()->id,
],
+ [
+ 'name' => 'FAQ',
+ 'icon' => 'mdi:help-circle',
+ 'url' => 'faqs',
+ 'status' => 1,
+ 'order' => 110,
+ 'parent_id' => null,
+ 'permission_id' => Permission::where('name', 'faq-list')->first()->id,
+ ],
];
foreach ($menus as $menu) {
diff --git a/database/seeders/PermissionTableSeeder.php b/database/seeders/PermissionTableSeeder.php
index 06dd024..2d19262 100644
--- a/database/seeders/PermissionTableSeeder.php
+++ b/database/seeders/PermissionTableSeeder.php
@@ -114,6 +114,11 @@ public function run()
'question-create',
'question-edit',
'question-delete',
+
+ 'faq-list',
+ 'faq-create',
+ 'faq-edit',
+ 'faq-delete',
];
foreach ($permissions as $permission) {
diff --git a/public/template-pdf/template.pdf b/public/template-pdf/template.pdf
new file mode 100644
index 0000000..94d6d8a
Binary files /dev/null and b/public/template-pdf/template.pdf differ
diff --git a/public/template-pdf/template_2-company.pdf b/public/template-pdf/template_2-company.pdf
new file mode 100644
index 0000000..b73ed10
Binary files /dev/null and b/public/template-pdf/template_2-company.pdf differ
diff --git a/public/template-pdf/template_3_month.pdf b/public/template-pdf/template_3_month.pdf
new file mode 100644
index 0000000..fc6ed6e
Binary files /dev/null and b/public/template-pdf/template_3_month.pdf differ
diff --git a/public/template-pdf/template_6_month.pdf b/public/template-pdf/template_6_month.pdf
new file mode 100644
index 0000000..aca27eb
Binary files /dev/null and b/public/template-pdf/template_6_month.pdf differ
diff --git a/public/uploads/.gitignore b/public/uploads/.gitignore
new file mode 100644
index 0000000..c96a04f
--- /dev/null
+++ b/public/uploads/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
\ No newline at end of file
diff --git a/resources/views/components/form/input-rich.blade.php b/resources/views/components/form/input-rich.blade.php
index 07978e9..4056197 100644
--- a/resources/views/components/form/input-rich.blade.php
+++ b/resources/views/components/form/input-rich.blade.php
@@ -7,9 +7,22 @@
-