...
protected $phone_number;
public function __construct()
{
$this->middleware('guest');
$this->phone_number = request()->input('phone');
}
protected function validator(array $data)
{
return Validator::make($data, [
...
'verification_code' => Rule::exists('phone_numbers', 'verification_code')->where(function ($query) use ($phone_number) {
$query->where('phone_number', $phone_number);
}),
]);
}
...
$phone_number = $this->phone_number;
'verification_code' => Rule::exists('phone_numbers', 'verification_code')->where(function ($query) {
$query->where('phone_number', $this->phone_number);
}),