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,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Models\Issue;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class IssueUpdateRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
$issue = $this->route('issue') ?? Issue::find($this->route('issue'));
|
||||
if ($issue) {
|
||||
return $this->user()->can('edit issues', $issue->project) && $this->user()->can('edit', $issue);
|
||||
}
|
||||
return $this->user()->can('edit issues');
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'sometimes|required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'status' => ['sometimes', 'required', Rule::in(Issue::STATUSES)],
|
||||
'priority' => ['sometimes', 'required', Rule::in(Issue::PRIORITIES)],
|
||||
'type' => ['sometimes', 'required', Rule::in(Issue::TYPES)],
|
||||
'assigned_to' => 'nullable|exists:users,id',
|
||||
'resolution_notes' => 'nullable|string',
|
||||
'feature_id' => 'nullable|exists:features,id',
|
||||
'inspection_id' => 'nullable|exists:inspections,id',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user