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