mirror of
https://github.com/archtechx/virtualcolumn.git
synced 2025-12-12 22:54:03 +00:00
Fix merge
This commit is contained in:
parent
36493d0a84
commit
955860d34a
1 changed files with 6 additions and 23 deletions
|
|
@ -114,8 +114,9 @@ class VirtualColumnTest extends TestCase
|
|||
// 'foo' is a custom column, 'data' is the virtual column
|
||||
FooChild::create(['foo' => 'foo']);
|
||||
$encodedFoo = DB::select('select * from foo_childs limit 1')[0];
|
||||
|
||||
// Assert that the model was encoded correctly
|
||||
$this->assertNull($encodedFoo->data);
|
||||
$this->assertSame($encodedFoo->data, '[]');
|
||||
$this->assertSame($encodedFoo->foo, 'foo');
|
||||
|
||||
// Create another child model of the same parent
|
||||
|
|
@ -123,7 +124,7 @@ class VirtualColumnTest extends TestCase
|
|||
BarChild::create(['bar' => 'bar']);
|
||||
$encodedBar = DB::select('select * from bar_childs limit 1')[0];
|
||||
|
||||
$this->assertNull($encodedBar->data);
|
||||
$this->assertSame($encodedBar->data, '[]');
|
||||
$this->assertSame($encodedBar->bar, 'bar');
|
||||
}
|
||||
|
||||
|
|
@ -164,17 +165,8 @@ class ParentModel extends Model
|
|||
{
|
||||
use VirtualColumn;
|
||||
|
||||
protected $guarded = [];
|
||||
public $timestamps = false;
|
||||
|
||||
public function getCustomColumns(): array
|
||||
{
|
||||
return [
|
||||
'id',
|
||||
'custom1',
|
||||
'custom2',
|
||||
];
|
||||
}
|
||||
protected $guarded = [];
|
||||
}
|
||||
|
||||
class MyModel extends ParentModel
|
||||
|
|
@ -210,20 +202,11 @@ class EncryptedCast implements CastsAttributes
|
|||
}
|
||||
}
|
||||
|
||||
class ParentModel extends Model
|
||||
{
|
||||
use VirtualColumn;
|
||||
|
||||
public $timestamps = false;
|
||||
protected $guarded = [];
|
||||
}
|
||||
|
||||
|
||||
class FooChild extends ParentModel
|
||||
{
|
||||
public $table = 'foo_childs';
|
||||
|
||||
public static function getCustomColumns(): array
|
||||
public function getCustomColumns(): array
|
||||
{
|
||||
return [
|
||||
'id',
|
||||
|
|
@ -235,7 +218,7 @@ class BarChild extends ParentModel
|
|||
{
|
||||
public $table = 'bar_childs';
|
||||
|
||||
public static function getCustomColumns(): array
|
||||
public function getCustomColumns(): array
|
||||
{
|
||||
return [
|
||||
'id',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue