- Work done on setting entities properties using array values
This commit is contained in:
parent
8e91c3a418
commit
bad5123447
|
@ -71,6 +71,7 @@ class EntityResolver {
|
|||
}
|
||||
|
||||
$fieldList[$key] = $item;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,6 +108,25 @@ trait EntityTrait {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function entityGetDataset() : array
|
||||
{
|
||||
$fields = array_keys($this->resolveEntity()->fieldList());
|
||||
|
||||
return array_combine($fields, array_map(function(string $key) {
|
||||
return $this->$key;
|
||||
}, $fields));
|
||||
}
|
||||
|
||||
public function __sleep()
|
||||
{
|
||||
return array_keys($this->resolveEntity()->fieldList());
|
||||
}
|
||||
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return $this->entityGetDataset();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Ignore
|
||||
*/
|
||||
|
@ -135,7 +154,7 @@ trait EntityTrait {
|
|||
/**
|
||||
* @Ignore
|
||||
*/
|
||||
public static function field($name, ? string $alias = null)
|
||||
public static function field($name, ? string $alias = null) : EntityField
|
||||
{
|
||||
return new EntityField(static::class, $name, $alias ?: Repository::DEFAULT_ALIAS);
|
||||
}
|
||||
|
@ -143,18 +162,10 @@ trait EntityTrait {
|
|||
/**
|
||||
* @Ignore
|
||||
*/
|
||||
public static function fields(...$fields)
|
||||
public static function fields(...$fields) : string
|
||||
{
|
||||
return implode(', ', array_map(function($name) {
|
||||
return static::field($name);
|
||||
}, $fields));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Ignore
|
||||
*/
|
||||
public static function table()
|
||||
{
|
||||
return "REFLECT TABLE";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -322,4 +322,9 @@ class Repository
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
public function table()
|
||||
{
|
||||
return "REFLECT TABLE";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue