diff --git a/app/Http/Requests/StudentPostRequest.php b/app/Http/Requests/StudentPostRequest.php index c726119..cbb0f33 100644 --- a/app/Http/Requests/StudentPostRequest.php +++ b/app/Http/Requests/StudentPostRequest.php @@ -29,7 +29,7 @@ class StudentPostRequest extends FormRequest '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)], + 'email' => ['required', 'string', 'lowercase', 'email', 'max:255', Rule::unique(User::class)->ignore($this->route('student')?->user->id), 'regex:/^(([^<>()\[\]\\.,;:\s@”]+(\.[^<>()\[\]\\.,;:\s@”]+)*)|(“.+”))@((\[[0–9]{1,3}\.[0–9]{1,3}\.[0–9]{1,3}\.[0–9]{1,3}])|(([a-zA-Z\-0–9]+\.)+[a-zA-Z]{2,}))$/'], 'password' => 'required|max:255', ]; } diff --git a/app/Http/Requests/TeacherPostRequest.php b/app/Http/Requests/TeacherPostRequest.php index 062dde2..eb4dfa2 100644 --- a/app/Http/Requests/TeacherPostRequest.php +++ b/app/Http/Requests/TeacherPostRequest.php @@ -28,7 +28,7 @@ class TeacherPostRequest extends FormRequest 'last_name' => 'required|max:255', 'middle_name' => 'required|max:255', 'birthday' => 'required|date', - 'email' => ['required', 'string', 'lowercase', 'email', 'max:255', Rule::unique(User::class)->ignore($this->route('teacher')?->user->id)], + 'email' => ['required', 'string', 'lowercase', 'email', 'max:255', Rule::unique(User::class)->ignore($this->route('teacher')?->user->id), 'regex:/^(([^<>()\[\]\\.,;:\s@”]+(\.[^<>()\[\]\\.,;:\s@”]+)*)|(“.+”))@((\[[0–9]{1,3}\.[0–9]{1,3}\.[0–9]{1,3}\.[0–9]{1,3}])|(([a-zA-Z\-0–9]+\.)+[a-zA-Z]{2,}))$/'], 'password' => 'required|max:255', ]; } diff --git a/app/Mail/UserCreated.php b/app/Mail/UserCreated.php new file mode 100644 index 0000000..27d94c8 --- /dev/null +++ b/app/Mail/UserCreated.php @@ -0,0 +1,52 @@ + + */ + public function attachments(): array + { + return []; + } +} diff --git a/app/Models/User.php b/app/Models/User.php index e6541ff..269f223 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -3,11 +3,15 @@ namespace App\Models; // use Illuminate\Contracts\Auth\MustVerifyEmail; + +use App\Observers\UserObserver; +use Illuminate\Database\Eloquent\Attributes\ObservedBy; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Relations\MorphTo; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; +#[ObservedBy(UserObserver::class)] class User extends Authenticatable { use HasFactory, Notifiable; diff --git a/app/Observers/UserObserver.php b/app/Observers/UserObserver.php new file mode 100644 index 0000000..e6520a2 --- /dev/null +++ b/app/Observers/UserObserver.php @@ -0,0 +1,18 @@ +send(new UserCreated(request()->all()['password'])); + } +} diff --git a/resources/views/mails/user_created.blade.php b/resources/views/mails/user_created.blade.php new file mode 100644 index 0000000..b0b23fc --- /dev/null +++ b/resources/views/mails/user_created.blade.php @@ -0,0 +1,3 @@ +
+ Ваш пароль для входа на {{ url('/') }}: {{ $password }} +
\ No newline at end of file