Aesthetic Fixes
This commit is contained in:
@@ -23,8 +23,10 @@ class TaskController extends Controller
|
||||
if ($projectUlid) {
|
||||
$project = Project::where('ulid', $projectUlid)->firstOrFail();
|
||||
$project->load([
|
||||
'milestones' => fn ($q) => $q->orderBy('sort_order'),
|
||||
'tasks' => fn ($q) => $q->with([
|
||||
'users:id,ulid,name',
|
||||
'milestone:id,ulid,name',
|
||||
'taskMaterials.material' => function ($query) {
|
||||
$query->select('id', 'ulid', 'name', 'unit', 'unit_cost', 'type')
|
||||
->with('components.component:id,name,unit');
|
||||
@@ -99,6 +101,7 @@ class TaskController extends Controller
|
||||
'estimated_hours' => 'nullable|numeric|min:0',
|
||||
'start_date' => 'nullable|date',
|
||||
'end_date' => 'nullable|date|after_or_equal:start_date',
|
||||
'milestone_id' => 'nullable|string|exists:project_milestones,ulid',
|
||||
]);
|
||||
|
||||
$project = Project::findOrFail($validated['project_id']);
|
||||
@@ -112,6 +115,17 @@ class TaskController extends Controller
|
||||
|
||||
$validated['sort_order'] = $project->tasks()->count();
|
||||
|
||||
if (empty($validated['labor_cost'])) {
|
||||
$validated['labor_cost'] = 0;
|
||||
}
|
||||
if (empty($validated['estimated_hours'])) {
|
||||
$validated['estimated_hours'] = 0;
|
||||
}
|
||||
|
||||
$validated['milestone_id'] = !empty($validated['milestone_id'])
|
||||
? \Modules\ProjectManagement\Models\ProjectMilestone::resolveUlidToId($validated['milestone_id'])
|
||||
: null;
|
||||
|
||||
$task = Task::create($validated);
|
||||
$task->users()->sync($userIds);
|
||||
|
||||
@@ -145,6 +159,7 @@ class TaskController extends Controller
|
||||
'start_date' => 'nullable|date',
|
||||
'end_date' => 'nullable|date|after_or_equal:start_date',
|
||||
'completion_percentage' => 'nullable|numeric|min:0|max:100',
|
||||
'milestone_id' => 'nullable|string|exists:project_milestones,ulid',
|
||||
]);
|
||||
|
||||
$userIds = [];
|
||||
@@ -155,6 +170,23 @@ class TaskController extends Controller
|
||||
}
|
||||
|
||||
$oldUserIds = $task->users()->pluck('users.id')->toArray();
|
||||
|
||||
if (array_key_exists('labor_cost', $validated) && empty($validated['labor_cost'])) {
|
||||
$validated['labor_cost'] = 0;
|
||||
}
|
||||
if (array_key_exists('estimated_hours', $validated) && empty($validated['estimated_hours'])) {
|
||||
$validated['estimated_hours'] = 0;
|
||||
}
|
||||
if (array_key_exists('actual_hours', $validated) && empty($validated['actual_hours'])) {
|
||||
$validated['actual_hours'] = 0;
|
||||
}
|
||||
|
||||
if (array_key_exists('milestone_id', $validated)) {
|
||||
$validated['milestone_id'] = !empty($validated['milestone_id'])
|
||||
? \Modules\ProjectManagement\Models\ProjectMilestone::resolveUlidToId($validated['milestone_id'])
|
||||
: null;
|
||||
}
|
||||
|
||||
$task->update($validated);
|
||||
$task->users()->sync($userIds);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user