mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-01-06 07:43:40 +08:00
27 lines
595 B
PHP
27 lines
595 B
PHP
|
<?php
|
||
|
|
||
|
namespace BookStack\Exports\ZipExports;
|
||
|
|
||
|
use Closure;
|
||
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||
|
|
||
|
class ZipUniqueIdRule implements ValidationRule
|
||
|
{
|
||
|
public function __construct(
|
||
|
protected ZipValidationHelper $context,
|
||
|
protected string $modelType,
|
||
|
) {
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* @inheritDoc
|
||
|
*/
|
||
|
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||
|
{
|
||
|
if ($this->context->hasIdBeenUsed($this->modelType, $value)) {
|
||
|
$fail('validation.zip_unique')->translate(['attribute' => $attribute]);
|
||
|
}
|
||
|
}
|
||
|
}
|