CourseWork/app/Http/Requests/TeacherPostRequest.php

36 lines
1.1 KiB
PHP
Raw Normal View History

2024-04-23 14:52:49 +04:00
<?php
namespace App\Http\Requests;
2024-06-24 01:28:58 +04:00
use App\Models\User;
2024-04-23 14:52:49 +04:00
use Illuminate\Foundation\Http\FormRequest;
2024-06-24 01:28:58 +04:00
use Illuminate\Validation\Rule;
2024-04-23 14:52:49 +04:00
class TeacherPostRequest 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',
2024-06-25 21:38:21 +04:00
'email' => ['required', 'string', 'lowercase', 'email', 'max:255', Rule::unique(User::class)->ignore($this->route('teacher')?->user->id), 'regex:/^(([^<>()\[\]\\.,;:\s@”]+(\.[^<>()\[\]\\.,;:\s@”]+)*)|(“.+”))@((\[[09]{1,3}\.[09]{1,3}\.[09]{1,3}\.[09]{1,3}])|(([a-zA-Z\-09]+\.)+[a-zA-Z]{2,}))$/'],
2024-04-23 14:52:49 +04:00
'password' => 'required|max:255',
];
}
}