Refactor Validators.
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-08-30 17:28:24 +03:00
parent f85bc047b8
commit b43759f3f4
8 changed files with 67 additions and 36 deletions
@@ -2,22 +2,13 @@
namespace App\Models\Validation\Validators;
use App\Models\Validation\Validators\Validator;
use App\Models\Validation\Validators\NextValidatorByName;
use App\Models\Item;
class ItemValidatorByName extends Validator {
private string $name;
protected Validator $nextValidator;
public function __construct(string $name, Validator $nextValidator)
{
$this->name = $name;
$this->nextValidator = $nextValidator;
}
class ItemValidatorByName extends NextValidatorByName {
public function isCurrentValid(): bool
{
$count = Item::where('name', $this->name)->count();
$count = Item::where('name', $this->getName())->count();
return $count != 0;
}