mirror of
https://github.com/archtechx/virtualcolumn.git
synced 2025-12-12 18:44:04 +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
|
// 'foo' is a custom column, 'data' is the virtual column
|
||||||
FooChild::create(['foo' => 'foo']);
|
FooChild::create(['foo' => 'foo']);
|
||||||
$encodedFoo = DB::select('select * from foo_childs limit 1')[0];
|
$encodedFoo = DB::select('select * from foo_childs limit 1')[0];
|
||||||
|
|
||||||
// Assert that the model was encoded correctly
|
// Assert that the model was encoded correctly
|
||||||
$this->assertNull($encodedFoo->data);
|
$this->assertSame($encodedFoo->data, '[]');
|
||||||
$this->assertSame($encodedFoo->foo, 'foo');
|
$this->assertSame($encodedFoo->foo, 'foo');
|
||||||
|
|
||||||
// Create another child model of the same parent
|
// Create another child model of the same parent
|
||||||
|
|
@ -123,7 +124,7 @@ class VirtualColumnTest extends TestCase
|
||||||
BarChild::create(['bar' => 'bar']);
|
BarChild::create(['bar' => 'bar']);
|
||||||
$encodedBar = DB::select('select * from bar_childs limit 1')[0];
|
$encodedBar = DB::select('select * from bar_childs limit 1')[0];
|
||||||
|
|
||||||
$this->assertNull($encodedBar->data);
|
$this->assertSame($encodedBar->data, '[]');
|
||||||
$this->assertSame($encodedBar->bar, 'bar');
|
$this->assertSame($encodedBar->bar, 'bar');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -164,17 +165,8 @@ class ParentModel extends Model
|
||||||
{
|
{
|
||||||
use VirtualColumn;
|
use VirtualColumn;
|
||||||
|
|
||||||
protected $guarded = [];
|
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
protected $guarded = [];
|
||||||
public function getCustomColumns(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'id',
|
|
||||||
'custom1',
|
|
||||||
'custom2',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyModel extends ParentModel
|
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
|
class FooChild extends ParentModel
|
||||||
{
|
{
|
||||||
public $table = 'foo_childs';
|
public $table = 'foo_childs';
|
||||||
|
|
||||||
public static function getCustomColumns(): array
|
public function getCustomColumns(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'id',
|
'id',
|
||||||
|
|
@ -235,7 +218,7 @@ class BarChild extends ParentModel
|
||||||
{
|
{
|
||||||
public $table = 'bar_childs';
|
public $table = 'bar_childs';
|
||||||
|
|
||||||
public static function getCustomColumns(): array
|
public function getCustomColumns(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'id',
|
'id',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue