Added validation in upload daily task report
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 16s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 15s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 21s
Laravel Pint / pint (pull_request) Successful in 3m38s
Laravel Larastan / larastan (pull_request) Failing after 4m57s

This commit is contained in:
dhanabalan
2026-10-27 08:57:00 +05:30
parent e3c07011ba
commit 7c123a2d1d

View File

@@ -59,31 +59,47 @@ class UploadDailyReport extends Page implements HasForms
$path = 'task_updates/' . $filename;
// $duplicateExists = Storage::disk('local')->exists($path);
$expectedEmployees = [
'Dhanabalan Saravanan',
'Ranjith',
'Srimathi Ramamoorthy',
];
// if ($duplicateExists) {
// // Remove the just-uploaded file since it's a duplicate
// // Storage::disk('local')->delete($currentFile);
$filename = pathinfo(basename($currentFile), PATHINFO_FILENAME);
// Notification::make()
// ->title('File already exists')
// ->body("A file named \"{$filename}\" is already uploaded.")
// ->danger()
// ->send();
$isValid = collect($expectedEmployees)->contains(
fn ($name) => strcasecmp(trim($filename), $name) == 0
);
// $this->form->fill(['report_pdf' => null]);
// return;
// }
// else{
if (! $isValid) {
Notification::make()
->title('PDF uploaded successfully')
->success()
->send();
->title('Invalid PDF filename')
->body(
'Please upload a PDF with one of these names: '
. implode(', ', array_map(
fn ($name) => $name . '.pdf',
$expectedEmployees
))
)
->danger()
->send();
$this->form->fill(['report_pdf' => null]);
// }
return;
}
else{
Notification::make()
->title('PDF uploaded successfully')
->success()
->send();
$this->form->fill(['report_pdf' => null]);
}
}
public function removeTaskPdf(){
$fileName = $this->filters['file_name'] ?? null;