mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
e973f68537
* feat(admin): upload video action * style: fix StyleCI findings * tests: fix video storage tests
49 lines
1001 B
PHP
49 lines
1001 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Rules\Wiki\Resource;
|
|
|
|
use App\Enums\Models\Wiki\ResourceSite;
|
|
use Illuminate\Contracts\Validation\Rule;
|
|
|
|
/**
|
|
* Class ResourceSiteMatchesLinkRule.
|
|
*/
|
|
class ResourceSiteMatchesLinkRule implements Rule
|
|
{
|
|
/**
|
|
* Create a new rule instance.
|
|
*
|
|
* @param string $link
|
|
* @return void
|
|
*/
|
|
public function __construct(protected readonly string $link)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Determine if the validation rule passes.
|
|
*
|
|
* @param string $attribute
|
|
* @param mixed $value
|
|
* @return bool
|
|
*/
|
|
public function passes($attribute, $value): bool
|
|
{
|
|
$domain = ResourceSite::getDomain($value);
|
|
|
|
return empty($domain) || $domain === parse_url($this->link, PHP_URL_HOST);
|
|
}
|
|
|
|
/**
|
|
* Get the validation error message.
|
|
*
|
|
* @return string|array
|
|
*/
|
|
public function message(): string|array
|
|
{
|
|
return __('validation.resource_link_site_mismatch');
|
|
}
|
|
}
|