39 lines
769 B
PHP
39 lines
769 B
PHP
<?php
|
|
|
|
namespace App\Rules;
|
|
|
|
use App\Models\Cadastro\SujeitoAtencao\Usuario;
|
|
use Illuminate\Contracts\Validation\Rule;
|
|
|
|
class SenhaFraca implements Rule
|
|
{
|
|
private $id;
|
|
|
|
public function __construct($id)
|
|
{
|
|
$this->id = $id;
|
|
}
|
|
|
|
public function passes($attribute, $value)
|
|
{
|
|
$usuario = Usuario::findOrFail($this->id);
|
|
|
|
$validacoes = ['nome', 'data_nascimento', 'email'];
|
|
|
|
foreach ($validacoes as $validacao) {
|
|
similar_text(strtoupper($value), strtoupper($usuario->cidadao[$validacao]), $porcentagem);
|
|
|
|
if ($porcentagem > 25) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public function message()
|
|
{
|
|
return 'A nova senha é fraca.';
|
|
}
|
|
}
|