Files
online.tbbank.gov.tm-larave…/app/Rules/PhoneCodeVerification.php
2023-12-02 14:45:27 +05:00

27 lines
694 B
PHP

<?php
namespace App\Rules;
use App\Models\System\Verification;
use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
class PhoneCodeVerification implements ValidationRule
{
/**
* Run the validation rule.
*
* @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail
*/
public function validate(string $attribute, mixed $value, Closure $fail): void
{
$verification = Verification::where('username', auth()->user()->phone)
->where('code', $request->verification_code)
->first();
if (! $verification) {
$fail(__('Write a correct data please'));
}
}
}