2018-10-17 14:26:27 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\ValidationRules;
|
|
|
|
|
2018-10-18 07:04:36 +02:00
|
|
|
use App\Libraries\MultiDB;
|
2018-10-17 14:26:27 +02:00
|
|
|
use App\Models\User;
|
|
|
|
use Illuminate\Contracts\Validation\Rule;
|
|
|
|
|
|
|
|
class UniqueUserRule implements Rule
|
|
|
|
{
|
|
|
|
|
|
|
|
public function passes($attribute, $value)
|
|
|
|
{
|
2018-10-18 07:04:36 +02:00
|
|
|
return ! $this->checkIfEmailExists($value); //if it exists, return false!
|
2018-10-17 14:26:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function message()
|
|
|
|
{
|
2019-01-25 11:47:23 +01:00
|
|
|
return ctrans('texts.email_already_register');
|
2018-10-17 14:26:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private function checkIfEmailExists($email) : bool
|
|
|
|
{
|
2018-10-18 07:04:36 +02:00
|
|
|
return MultiDB::checkUserEmailExists($email);
|
2018-10-17 14:26:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|