- Added a default searchRequest() method to entityTrait
This commit is contained in:
1 parent
d01624b8aa
commit
338b599d39
2 files changed
+72
-5
No files matched your search
@@ -19,7 +19,7 @@ class FieldDefinition {
|
||||
|
||||
public array $tags;
|
||||
|
||||
public /* ? string */ $default;
|
||||
public mixed $default;
|
||||
|
||||
public ? int $precision;
|
||||
|
||||
@@ -37,6 +37,10 @@ class FieldDefinition {
|
||||
$this->builtIn = $data['builtin'];
|
||||
$this->tags = $data['tags'];
|
||||
|
||||
if (isset($data['value'])) {
|
||||
$this->default = $data['value'];
|
||||
}
|
||||
|
||||
$field = $this->getFieldTag();
|
||||
$adapter->whitelistAttributes($field->attributes);
|
||||
|
||||
@@ -66,7 +70,7 @@ class FieldDefinition {
|
||||
$this->isUnsigned() ? $syntax['unsigned'] : null,
|
||||
$this->nullable ? "NULL" : "NOT NULL",
|
||||
$this->update ? "ON UPDATE {$this->update}" : null,
|
||||
$default ? "DEFAULT $default" : null,
|
||||
$default !== null ? "DEFAULT $default" : null,
|
||||
$this->isPrimaryKey() ? $syntax['pk'] : null,
|
||||
$this->isAutoIncrement() ? $syntax['ai'] : null,
|
||||
]));
|
||||
@@ -84,9 +88,20 @@ class FieldDefinition {
|
||||
return $this->getFieldTag()->name ?? $this->name;
|
||||
}
|
||||
|
||||
public function getDefault() : ? string
|
||||
public function getDefault() : mixed
|
||||
{
|
||||
return $this->getFieldTag()->attributes['default'] ?? ( $this->nullable ? "NULL" : null ) ;
|
||||
if ( isset($this->default) ) {
|
||||
if (is_bool($this->default)) {
|
||||
return (int) $this->default;
|
||||
}
|
||||
|
||||
# Specific default cases here ..
|
||||
|
||||
return $this->default;
|
||||
}
|
||||
|
||||
# Fallback on attribute's default value
|
||||
return $this->getFieldTag()->default ?? ( $this->nullable ? "NULL" : null ) ;
|
||||
}
|
||||
|
||||
public function isPrimaryKey() : bool
|
||||
|
||||
Reference in new issue
Block a user