Media::whereNull('uuid')->cursor()->each(
fn(Media $media) => $media->update(['uuid' => Str::uuid()])
);
+
+ $this->_handleMagicFolder([$this, '_postMigrate']);
}
/**
}
}
+ /**
+ * @param $model CubistMagicAbstractModel
+ */
+ public function _postMigrate($model)
+ {
+ $this->line('Handling ' . get_class($model) . ' for post operations');
+
+ $res = $model->postSetSchema();
+ if (null !== $res) {
+ $this->line('-- Post Migration ' . $res->getName());
+ }
+ }
+
protected function _getSchema($connection)
{
if (!isset($this->_schemas[$connection])) {
return $table;
}
+ public function postSetSchema()
+ {
+ $this->_createOneInstance();
+ }
+
/**
* @param $table Table
*/
public function onBeforeEdit($controller, $id)
{
- if ($this->getOption('oneinstance', false)) {
- if (null === static::find($id)) {
- $class = get_called_class();
- $new = new $class([$this->primaryKey, $id]);
- $new->save();
- }
+ $this->_createOneInstance($id);
+ }
+
+ protected function _createOneInstance($id = 1)
+ {
+ if ($this->getOption('oneinstance', false) && null === static::find($id)) {
+ $class = get_called_class();
+ $new = new $class([$this->primaryKey, $id]);
+ $new->save();
}
}
return false;
}
$permission = $this->getOption('name') . ':' . $operation;
- return $user->hasPermissionTo($permission);
+ return $user->can($permission);
}
/**