mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
no message
This commit is contained in:
1 parent
34b2dc6526
commit
b101da8da5
2 files changed
+24
-5
No files matched your search
@@ -418,13 +418,32 @@ class SubTaskController extends Controller
|
||||
], 400);
|
||||
}
|
||||
|
||||
// Validácia - každý zamestnanec musí mať id a duration
|
||||
foreach ($employees as $employee) {
|
||||
if (!isset($employee['id']) || !isset($employee['duration'])) {
|
||||
// Validácia a doplnenie duration z timeblocks
|
||||
foreach ($employees as $key => $employee) {
|
||||
if (!isset($employee['id'])) {
|
||||
return response()->json([
|
||||
'message' => 'Draft cannot be published. Each employee must have id and duration.',
|
||||
'message' => 'Draft cannot be published. Each employee must have id.',
|
||||
], 400);
|
||||
}
|
||||
|
||||
// Ak duration nie je nastavený, vypočítaj ho z timeblocks
|
||||
if (!isset($employee['duration']) || $employee['duration'] === null) {
|
||||
if (isset($employee['timeblocks']) && !empty($employee['timeblocks'])) {
|
||||
$totalDuration = 0;
|
||||
foreach ($employee['timeblocks'] as $timeblock) {
|
||||
if (isset($timeblock['start']) && isset($timeblock['end'])) {
|
||||
$start = Carbon::parse($timeblock['start']);
|
||||
$end = Carbon::parse($timeblock['end']);
|
||||
$totalDuration += $end->diffInMinutes($start);
|
||||
}
|
||||
}
|
||||
$employees[$key]['duration'] = $totalDuration;
|
||||
} else {
|
||||
return response()->json([
|
||||
'message' => 'Draft cannot be published. Each employee must have duration or timeblocks.',
|
||||
], 400);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$mastertask = $draft->mastertask;
|
||||
|
||||
Reference in new issue
Block a user