- Created LetterRequestRequest and LetterRequestStatusRequest for handling form requests. - Removed the old LetterRequestRequest class and updated the authorization logic. - Changed the student relationship to user in the LetterRequest model. - Updated LetterRequestService to reflect changes in the model and request handling. - Modified permission catalog to include new permissions for letter request status updates. - Updated database migrations and seeders to use user_id instead of student_id. - Removed student-specific letter request pages and components, consolidating functionality under admin routes. - Adjusted frontend components to accommodate new data structure and permissions. - Enhanced the letter request columns to support status updates directly from the table.
31 lines
797 B
PHP
31 lines
797 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Admin\Services\LetterRequest;
|
|
|
|
use App\Enums\LetterStatus;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class LetterRequestRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
if ($this->isMethod('post')) {
|
|
return $this->user()->can('create-letter-requests');
|
|
}
|
|
|
|
$letterRequest = $this->route('letter_request');
|
|
|
|
return $this->user()->can('update-letter-requests')
|
|
&& $letterRequest->user_id === $this->user()->id
|
|
&& $letterRequest->status === LetterStatus::Submitted->value;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'letter_type' => ['required', 'string', 'max:100'],
|
|
'purpose' => ['nullable', 'string'],
|
|
];
|
|
}
|
|
}
|