71 lines
3.0 KiB
PHP
71 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace Modules\DailyReports\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class StoreDailyReportRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'project_id' => ['required', 'exists:projects,id'],
|
|
'report_date' => ['required', 'date'],
|
|
'report_number' => ['nullable', 'string', 'max:255'],
|
|
'temperature' => ['nullable', 'string', 'max:255'],
|
|
'precipitation' => ['nullable', 'string', 'max:255'],
|
|
'wind' => ['nullable', 'string', 'max:255'],
|
|
'weather' => ['nullable', 'string', 'max:255'],
|
|
'start_time' => ['nullable', 'string', 'max:20'],
|
|
'end_time' => ['nullable', 'string', 'max:20'],
|
|
'remarks' => ['required', 'string', 'min:3'],
|
|
|
|
// Nested relations
|
|
'labors' => ['nullable', 'array'],
|
|
'labors.*.trade' => ['required', 'string', 'max:255'],
|
|
'labors.*.workers_count' => ['required', 'numeric', 'min:1'],
|
|
'labors.*.hours' => ['required', 'numeric', 'min:0.5'],
|
|
'labors.*.notes' => ['nullable', 'string'],
|
|
|
|
'equipment' => ['nullable', 'array'],
|
|
'equipment.*.equipment_name' => ['required', 'string', 'max:255'],
|
|
'equipment.*.hours_used' => ['required', 'numeric', 'min:0.5'],
|
|
'equipment.*.status' => ['required', 'string', 'max:255'],
|
|
|
|
'activities' => ['nullable', 'array'],
|
|
'activities.*.task_name' => ['required', 'string', 'max:255'],
|
|
'activities.*.quantity_completed' => ['required', 'numeric', 'min:0'],
|
|
'activities.*.percentage_completed' => ['required', 'numeric', 'min:0', 'max:100'],
|
|
'activities.*.zone_area' => ['nullable', 'string', 'max:255'],
|
|
'activities.*.evidence' => ['nullable', 'array'],
|
|
'activities.*.evidence.*' => ['file', 'max:10240'],
|
|
|
|
'materials' => ['nullable', 'array'],
|
|
'materials.*.material_name' => ['required', 'string', 'max:255'],
|
|
'materials.*.quantity' => ['required', 'numeric', 'min:0.01'],
|
|
'materials.*.unit' => ['required', 'string', 'max:50'],
|
|
'materials.*.condition' => ['nullable', 'string', 'max:255'],
|
|
'materials.*.remarks' => ['nullable', 'string', 'max:255'],
|
|
|
|
'issues' => ['nullable', 'array'],
|
|
'issues.*.issue_type' => ['required', 'string', 'max:255'],
|
|
'issues.*.description' => ['required', 'string'],
|
|
'issues.*.delay_impact' => ['required', 'string', 'max:255'],
|
|
|
|
'attachments' => ['nullable', 'array'],
|
|
'attachments.*' => ['file', 'max:10240'],
|
|
];
|
|
}
|
|
}
|