turtle-wow-source-kinda/Dumps/Source Code/8 - Development_website/master/app/Rules/CurrentEmail.php

25 lines
595 B
PHP
Raw Normal View History

2024-08-06 16:06:40 +00:00
<?php
namespace App\Rules;
use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Support\Facades\Auth;
class CurrentEmail implements ValidationRule
{
/**
* Run the validation rule.
*
* @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail
*/
public function validate(string $attribute, mixed $value, Closure $fail): void
{
$user = Auth::guard('account')->user();
if ($user->email != $value) {
$fail(__('change_email_modal')['exception']['current_email']);
}
}
}