<?php namespace App\Http\Requests; use App\Models\User; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Validation\Rule; class StudentPostRequest 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. * * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string> */ public function rules(): array { return [ 'name' => 'required|max:255', 'last_name' => 'required|max:255', 'middle_name' => 'required|max:255', 'birthday' => 'required|date', 'grade_id' => 'required|exists:grades,id', 'email' => ['required', 'string', 'lowercase', 'email', 'max:255', Rule::unique(User::class)->ignore($this->route('student')?->user->id)], 'password' => 'required|max:255', ]; } }