*/
protected $translatable = [];
+ /**
+ * @var array
+ */
+ protected $fakeColumns = [];
+
/**
* @var Field[]
$name = $field->getAttribute('name');
$this->_fields[$name] = $field;
- if ($field->getAttribute('fillable')) {
- $this->fillable[] = $name;
- }
- if ($field->getAttribute('guarded')) {
- $this->guarded[] = $name;
- }
- if ($field->getAttribute('hidden')) {
- $this->hidden[] = $name;
- }
- if ($field->getAttribute('translatable')) {
- $this->translatable[] = $name;
- }
- if ($field->getAttribute('cast', false) !== false) {
- $this->casts[$field->getAttribute('name')] = $field->getAttribute('name');
+
+ if ($field->getAttribute('fake', false) === true) {
+ $store_in = $field->getAttribute('store_in');
+ if (!in_array($store_in, $this->fillable)) {
+ $this->fillable[] = $store_in;
+ }
+ if (!isset($this->casts[$store_in])) {
+ $this->casts[$store_in] = 'array';
+ }
+ if (!in_array($store_in, $this->fakeColumns)) {
+ $this->fakeColumns[] = $store_in;
+ }
+ } else {
+ if ($field->getAttribute('fillable')) {
+ $this->fillable[] = $name;
+ }
+ if ($field->getAttribute('guarded')) {
+ $this->guarded[] = $name;
+ }
+ if ($field->getAttribute('hidden')) {
+ $this->hidden[] = $name;
+ }
+ if ($field->getAttribute('translatable')) {
+ $this->translatable[] = $name;
+ }
+ if ($field->getAttribute('cast', false) !== false) {
+ $this->casts[$field->getAttribute('name')] = $field->getAttribute('name');
+ }
}
'PLURAL' => $this->getOption('plural', ''),
'MODELNAMESPACE' => get_class($this),
'EXTENDS' => $this->_getBaseController(),
- 'CLONABLE' => $this->clonable ? 'true' : 'false'
+ 'CLONABLE' => $this->clonable ? 'true' : 'false',
+ 'BULK' => $this->getOption('bulk', true) ? 'true' : 'false'
];
$res = file_get_contents($stub);