--- /dev/null
+<?php
+
+namespace Cubist\Backpack\Magic\Fields;
+
+class Composed extends Hidden
+{
+ protected string $_attribute = '';
+
+ public function getDefaultAttributes()
+ {
+ return array_merge(parent::getDefaultAttributes(), ['attribute' => $this->_attribute]);
+ }
+}
return $user->can($permission);
}
+ protected function getAttributesForInsert()
+ {
+ $res=parent::getAttributesForInsert();
+ foreach ($res as $k=>$v) {
+ if(is_array($v) || is_object($v)){
+ $res[$k]=json_encode($v);
+ }
+ }
+ return $res;
+ }
/**
* @param $user CubistMagicAuthenticatable
}
return null;
}
+
+ public function save(array $options = [])
+ {
+ $this->mergeAttributesFromCachedCasts();
+
+ $query = $this->newModelQuery();
+
+ // If the "saving" event returns false we'll bail out of the save and return
+ // false, indicating that the save failed. This provides a chance for any
+ // listeners to cancel save operations if validations fail or whatever.
+ if ($this->fireModelEvent('saving') === false) {
+ return false;
+ }
+
+ // If the model already exists in the database we can just update our record
+ // that is already in this database using the current IDs in this "where"
+ // clause to only update this model. Otherwise, we'll just insert them.
+ if ($this->exists) {
+ $saved = $this->isDirty() ?
+ $this->performUpdate($query) : true;
+ }
+
+ // If the model is brand new, we'll insert it into our database and set the
+ // ID attribute on the model to the value of the newly inserted row's ID
+ // which is typically an auto-increment value managed by the database.
+ else {
+ $saved = $this->performInsert($query);
+
+ if (! $this->getConnectionName() &&
+ $connection = $query->getConnection()) {
+ $this->setConnection($connection->getName());
+ }
+ }
+
+ // If the model is successfully saved, we need to do a few more things once
+ // that is done. We will call the "saved" method here to run any actions
+ // we need to happen after a model gets successfully saved right here.
+ if ($saved) {
+ $this->finishSave($options);
+ }
+
+ return $saved;
+ }
}