mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
huge Laravel 10 upgrade
This commit is contained in:
33
support/laravel-translation/src/Rules/LanguageNotExists.php
Normal file
33
support/laravel-translation/src/Rules/LanguageNotExists.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace JoeDixon\Translation\Rules;
|
||||
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
use JoeDixon\Translation\Drivers\Translation;
|
||||
|
||||
class LanguageNotExists implements Rule
|
||||
{
|
||||
/**
|
||||
* Determine if the validation rule passes.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
$translation = app()->make(Translation::class);
|
||||
|
||||
return ! $translation->languageExists($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function message()
|
||||
{
|
||||
return __('translation::translation.language_exists');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user