-
-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated to support Laravel 9, the package now utilizes the deprecated…
… InvokableRule interface instead of the new one introduced in Laravel 10. Future updates will accommodate the removal of Laravel 9 support.
- Loading branch information
1 parent
b46b3cc
commit 4f7a959
Showing
2 changed files
with
34 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
namespace Astrotomic\Translatable\Validation\Rules; | ||
|
||
use Closure; | ||
use Illuminate\Contracts\Validation\ValidationRule; | ||
use Illuminate\Contracts\Validation\InvokableRule; | ||
use Illuminate\Database\Eloquent\Builder; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Support\Str; | ||
|
@@ -14,8 +14,11 @@ | |
* Custom exists validation for translatable attributes | ||
* | ||
* @author Amjad BaniMattar <[email protected]> | ||
* | ||
* @TODO should be updated to use use Illuminate\Contracts\Validation\ValidationRule; when this package drop of Laravel 9 support | ||
* instead using detracted interface InvokableRule | ||
*/ | ||
class TranslatableExists implements ValidationRule | ||
class TranslatableExists implements InvokableRule | ||
{ | ||
/** | ||
* The ID that should be ignored. | ||
|
@@ -102,4 +105,16 @@ public function validate(string $attribute, mixed $value, Closure $fail): void | |
} | ||
} | ||
} | ||
|
||
/** | ||
* Laravel 9 compatibility (InvokableRule interface) | ||
* | ||
* @param string $attribute | ||
* @param mixed $value | ||
* @param Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail | ||
*/ | ||
public function __invoke($attribute, $value, $fail): void | ||
{ | ||
$this->validate($attribute, $value, $fail); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,14 +5,17 @@ | |
namespace Astrotomic\Translatable\Validation\Rules; | ||
|
||
use Closure; | ||
use Illuminate\Contracts\Validation\ValidationRule; | ||
use Illuminate\Contracts\Validation\InvokableRule; | ||
|
||
/** | ||
* Custom unique validation for translatable attributes | ||
* | ||
* @TODO should be updated to use use Illuminate\Contracts\Validation\ValidationRule; when this package drop of Laravel 9 support | ||
* instead using detracted interface InvokableRule | ||
* | ||
* @author Amjad BaniMattar <[email protected]> | ||
*/ | ||
class TranslatableUnique extends TranslatableExists implements ValidationRule | ||
class TranslatableUnique extends TranslatableExists implements InvokableRule | ||
{ | ||
/** | ||
* Validate if the given attribute is unique. | ||
|
@@ -33,4 +36,16 @@ public function validate(string $attribute, mixed $value, Closure $fail): void | |
} | ||
} | ||
} | ||
|
||
/** | ||
* Laravel 9 compatibility (InvokableRule interface) | ||
* | ||
* @param string $attribute | ||
* @param mixed $value | ||
* @param Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail | ||
*/ | ||
public function __invoke($attribute, $value, $fail): void | ||
{ | ||
$this->validate($attribute, $value, $fail); | ||
} | ||
} |