(a) адрес электронной почты должен заканчиваться на .com, .gov, got, co, . Великобритания и т. д.
(б)адрес электронной почты должен быть уникальным
Код: Выделить всё
public $email = '';
protected $rules = [
'email' => 'required|email|min:3|unique:subscribers,email|regex:/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-z]{2,3}$/',
];
protected $messages = [
'email.required' => 'The email field is required.',
'email.email' => 'Please provide a valid email address.',
'email.unique' => 'This email is already subscribed.',
'email.regex' => 'The email must be a valid format (e.g., must include ".com").',
];
public function updated($propertyName)
{
$this->validateOnly($propertyName);
}
public function submit()
{
$validated = $this->validate();
// Save the email to the subscribers table
Subscriber::create(['email' => $this->email]);
// Send email
Mail::to($this->email)->send(new SubscriptionMail($this->email));
$this->reset();
session()->flash('success', 'You have subscribed successfully!');
}
Подробнее здесь: https://stackoverflow.com/questions/787 ... l-livewire
Мобильная версия