From 56620956da3f0e8a697dd194fbf20e0358a20686 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Tue, 17 Oct 2023 09:47:09 +0200 Subject: [PATCH] Add base class that uses VirtualColumn in tests --- tests/VirtualColumnTest.php | 40 ++++++++++++++----------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/tests/VirtualColumnTest.php b/tests/VirtualColumnTest.php index 21418f7..cd0fea9 100644 --- a/tests/VirtualColumnTest.php +++ b/tests/VirtualColumnTest.php @@ -140,22 +140,14 @@ class VirtualColumnTest extends TestCase } } -class MyModel extends Model +class ParentModel extends Model { use VirtualColumn; protected $guarded = []; public $timestamps = false; - public $casts = [ - 'password' => 'encrypted', - 'array' => 'encrypted:array', - 'collection' => 'encrypted:collection', - 'json' => 'encrypted:json', - 'object' => 'encrypted:object', - 'custom' => EncryptedCast::class, - ]; - public static function getCustomColumns(): array + public function getCustomColumns(): array { return [ 'id', @@ -165,23 +157,21 @@ class MyModel extends Model } } -class FooModel extends Model +class MyModel extends ParentModel { - use VirtualColumn; + public $casts = [ + 'password' => 'encrypted', + 'array' => 'encrypted:array', + 'collection' => 'encrypted:collection', + 'json' => 'encrypted:json', + 'object' => 'encrypted:object', + 'custom' => EncryptedCast::class, + ]; +} - protected $guarded = []; - public $timestamps = false; - - public static function getCustomColumns(): array - { - return [ - 'id', - 'custom1', - 'custom2', - ]; - } - - public static function getDataColumn(): string +class FooModel extends ParentModel +{ + public function getDataColumn(): string { return 'virtual'; }