feat: Phase 3.1 - FormRequests for Task, Issue, Inspection
- Create TaskStoreRequest, TaskUpdateRequest with authorize() + rules() - Create IssueStoreRequest, IssueUpdateRequest with authorize() + rules() - Create InspectionStoreRequest, InspectionUpdateRequest with authorize() + rules() + withValidator() - Update TaskForm to use FormRequests via app() - Update IssueForm (kept inline validation for complex logic) - Add InspectionStore/Update requests for ProjectMap inspection methods Tests: 101 passing (319 assertions)
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Models\Issue;
|
||||
use App\Models\Project;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class IssueStoreRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
$project = $this->route('project') ?? Project::find($this->input('project_id'));
|
||||
if ($project) {
|
||||
return $this->user()->can('create issues', $project);
|
||||
}
|
||||
return $this->user()->can('create issues');
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'status' => ['required', Rule::in(Issue::STATUSES)],
|
||||
'priority' => ['required', Rule::in(Issue::PRIORITIES)],
|
||||
'type' => ['required', Rule::in(Issue::TYPES)],
|
||||
'assignedTo' => 'nullable|exists:users,id',
|
||||
'resolutionNotes' => 'nullable|string',
|
||||
'featureId' => 'nullable|exists:features,id',
|
||||
'inspectionId' => 'nullable|exists:inspections,id',
|
||||
'project_id' => 'required|exists:projects,id',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user