From b5ac5440b8a5ad3f47b648e0ce5e4e110e965ff7 Mon Sep 17 00:00:00 2001 From: Sergej Date: Mon, 23 Nov 2020 05:41:07 +0100 Subject: [PATCH] Observe only if instance of ValidableContract --- src/Validable.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Validable.php b/src/Validable.php index c72a730..1184497 100644 --- a/src/Validable.php +++ b/src/Validable.php @@ -4,6 +4,7 @@ use Sofa\Eloquence\Validable\Observer; use Illuminate\Contracts\Validation\Factory; +use Sofa\Eloquence\Contracts\Validable as ValidableContract; /** * @method integer getKey() @@ -48,7 +49,9 @@ trait Validable */ public static function bootValidable() { - static::observe(new Observer); + if (is_subclass_of(static::class, ValidableContract::class)) { + static::observe(new Observer); + } if (!static::$validatorFactory) { if (function_exists('app') && app()->bound('validator')) {