mirror of
https://github.com/archtechx/virtualcolumn.git
synced 2025-12-12 18:44:04 +00:00
Add base class that uses VirtualColumn in tests
This commit is contained in:
parent
8b6db9ac2a
commit
56620956da
1 changed files with 15 additions and 25 deletions
|
|
@ -140,12 +140,25 @@ class VirtualColumnTest extends TestCase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyModel extends Model
|
class ParentModel extends Model
|
||||||
{
|
{
|
||||||
use VirtualColumn;
|
use VirtualColumn;
|
||||||
|
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
|
public function getCustomColumns(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id',
|
||||||
|
'custom1',
|
||||||
|
'custom2',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyModel extends ParentModel
|
||||||
|
{
|
||||||
public $casts = [
|
public $casts = [
|
||||||
'password' => 'encrypted',
|
'password' => 'encrypted',
|
||||||
'array' => 'encrypted:array',
|
'array' => 'encrypted:array',
|
||||||
|
|
@ -154,34 +167,11 @@ class MyModel extends Model
|
||||||
'object' => 'encrypted:object',
|
'object' => 'encrypted:object',
|
||||||
'custom' => EncryptedCast::class,
|
'custom' => EncryptedCast::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
public static function getCustomColumns(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'id',
|
|
||||||
'custom1',
|
|
||||||
'custom2',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class FooModel extends Model
|
class FooModel extends ParentModel
|
||||||
{
|
{
|
||||||
use VirtualColumn;
|
public function getDataColumn(): string
|
||||||
|
|
||||||
protected $guarded = [];
|
|
||||||
public $timestamps = false;
|
|
||||||
|
|
||||||
public static function getCustomColumns(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'id',
|
|
||||||
'custom1',
|
|
||||||
'custom2',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getDataColumn(): string
|
|
||||||
{
|
{
|
||||||
return 'virtual';
|
return 'virtual';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue