use Cubist\Util\Files\Files;
use Cubist\Util\Graphics\Image;
use Cubist\Util\Json;
+use Cubist\Util\Str;
use Datetime;
use Illuminate\Support\Facades\Artisan;
{
$this->setComposedAttributes();
$this->checkHash();
+ $this->checkCID();
$this->checkExternalServers();
if ($this->_compositionUpdated) {
$this->setAttribute('composition_updated_at', new Datetime());
return parent::onSaving();
}
+ protected function checkCID()
+ {
+ if (!$this->cid) {
+ while (true) {
+ $this->cid = Str::random(8);
+ if (static::withoutGlobalScopes()->where('cid', $this->cid)->get()->count() === 0) {
+ break;
+ }
+ }
+ }
+ }
+
protected function checkExternalServers()
{
$o = ArrayUtil::asArray($this->install_online);
$res = $l10n[$defaultLocale];
if ($this->translations) {
- if(is_string($this->translations)) {
+ if (is_string($this->translations)) {
if (Json::isJson($this->translations)) {
$this->translations = json_decode($this->translations);
- }else{
- $this->translations=[];
+ } else {
+ $this->translations = [];
}
}
foreach ($this->translations as $k => $v) {
$current = static::find($this->id);
}
$new = $current->replicate($except);
- if (backpack_user()) {
- $new->owner = backpack_user()->id;
- }
$new->status = 0;
$new->title = __('Copie de :title', ['title' => $new->title]);
$new->visits_counter = 0;
+ $new->hash = '';
+ $new->cid = '';
return $new;
}