@@ -45,7 +45,7 @@ |
||
| 45 | 45 | |
| 46 | 46 | public static function boot() |
| 47 | 47 | { |
| 48 | - Route::group(['namespace' => 'Epesi\FileStorage'], function(){ |
|
| 48 | + Route::group(['namespace' => 'Epesi\FileStorage'], function() { |
|
| 49 | 49 | Route::get('file', 'FileStorageController@get')->middleware('web', FileStorageAccess::class); |
| 50 | 50 | }); |
| 51 | 51 | |
@@ -100,7 +100,7 @@ |
||
| 100 | 100 | |
| 101 | 101 | $path = self::getStoragePath($hash); |
| 102 | 102 | |
| 103 | - if (! self::storage()->exists($path)) { |
|
| 103 | + if (!self::storage()->exists($path)) { |
|
| 104 | 104 | self::storage()->put($path, $content); |
| 105 | 105 | } |
| 106 | 106 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | return $cache[$id]; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - if (! $meta = self::with('file')->find($id)) { |
|
| 48 | + if (!$meta = self::with('file')->find($id)) { |
|
| 49 | 49 | throw new StorageNotFound('Exception - DB storage object not found: ' . $id); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | try { |
| 110 | 110 | $meta = is_numeric($idOrMeta) ? self::get($idOrMeta) : $idOrMeta; |
| 111 | 111 | |
| 112 | - if (! file_exists($meta->file->path)) { |
|
| 112 | + if (!file_exists($meta->file->path)) { |
|
| 113 | 113 | throw new FileNotFound('Exception - file not found: ' . $meta->file->path); |
| 114 | 114 | } |
| 115 | 115 | } catch (\Exception $exception) { |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | { |
| 135 | 135 | $ids = []; |
| 136 | 136 | foreach ((array) $files as $file) { |
| 137 | - if (! is_numeric($file)) { |
|
| 137 | + if (!is_numeric($file)) { |
|
| 138 | 138 | $ids[] = self::put($file); |
| 139 | 139 | |
| 140 | 140 | continue; |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | public static function put($metaOrFile, $content = null) |
| 168 | 168 | { |
| 169 | 169 | $meta = $metaOrFile; |
| 170 | - if (! $content && is_string($metaOrFile)) { |
|
| 170 | + if (!$content && is_string($metaOrFile)) { |
|
| 171 | 171 | $content = file_get_contents($metaOrFile); |
| 172 | 172 | |
| 173 | 173 | $meta = [ |
@@ -180,11 +180,11 @@ discard block |
||
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | if ($file = $meta['file']?? null) { |
| 183 | - $path = is_array($file)? $file['path']: $file; |
|
| 183 | + $path = is_array($file) ? $file['path'] : $file; |
|
| 184 | 184 | |
| 185 | 185 | $meta['name'] = $meta['name']?? basename($path); |
| 186 | 186 | |
| 187 | - $content = $content?: file_get_contents($path); |
|
| 187 | + $content = $content ?: file_get_contents($path); |
|
| 188 | 188 | |
| 189 | 189 | unset($meta['file']); |
| 190 | 190 | } |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | |
| 199 | 199 | public function getThumbnailAttribute() |
| 200 | 200 | { |
| 201 | - if (! $this->thumbnailPossible()) return false; |
|
| 201 | + if (!$this->thumbnailPossible()) return false; |
|
| 202 | 202 | |
| 203 | 203 | $image = new \Imagick($this->meta->file->path . '[0]'); |
| 204 | 204 | |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | return self::create([ |
| 22 | 22 | 'meta_id' => $metaId, |
| 23 | 23 | 'token' => md5(uniqid(rand(), true)), |
| 24 | - 'created_by' => Auth::id()?: 0, |
|
| 24 | + 'created_by' => Auth::id() ?: 0, |
|
| 25 | 25 | 'expires_at' => date('Y-m-d H:i:s', strtotime($expires)), |
| 26 | 26 | ]); |
| 27 | 27 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | { |
| 16 | 16 | $this->down(); |
| 17 | 17 | |
| 18 | - Schema::create('filestorage_files', function (Blueprint $table) { |
|
| 18 | + Schema::create('filestorage_files', function(Blueprint $table) { |
|
| 19 | 19 | $table->bigIncrements('id'); |
| 20 | 20 | $table->string('hash', 128); |
| 21 | 21 | $table->integer('size'); |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | $table->softDeletes(); |
| 25 | 25 | }); |
| 26 | 26 | |
| 27 | - Schema::create('filestorage_meta', function (Blueprint $table) { |
|
| 27 | + Schema::create('filestorage_meta', function(Blueprint $table) { |
|
| 28 | 28 | $table->bigIncrements('id'); |
| 29 | 29 | $table->string('name', 256); |
| 30 | 30 | $table->string('link', 128)->nullable(); |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | $table->foreign('created_by')->references('id')->on('users'); |
| 40 | 40 | }); |
| 41 | 41 | |
| 42 | - Schema::create('filestorage_remote', function (Blueprint $table) { |
|
| 42 | + Schema::create('filestorage_remote', function(Blueprint $table) { |
|
| 43 | 43 | $table->bigIncrements('id'); |
| 44 | 44 | $table->unsignedBigInteger('meta_id'); |
| 45 | 45 | $table->string('token', 128); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | $table->foreign('created_by')->references('id')->on('users'); |
| 52 | 52 | }); |
| 53 | 53 | |
| 54 | - Schema::create('filestorage_access_log', function (Blueprint $table) { |
|
| 54 | + Schema::create('filestorage_access_log', function(Blueprint $table) { |
|
| 55 | 55 | $table->bigIncrements('id'); |
| 56 | 56 | $table->unsignedBigInteger('meta_id'); |
| 57 | 57 | $table->timestamp('accessed_at'); |
@@ -47,14 +47,14 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | $this->grid->setModel($model = $this->getModel()); |
| 49 | 49 | |
| 50 | - if ($model->action('count')->getOne() ) { |
|
| 50 | + if ($model->action('count')->getOne()) { |
|
| 51 | 51 | $this->grid->on('click', 'td', new jsExpression( |
| 52 | 52 | 'document.location=\'?parentId=\'+[]', |
| 53 | 53 | [(new jQuery())->closest('tr')->data('id')] |
| 54 | 54 | )); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - $this->grid->addDragHandler()->onReorder(function ($order) { |
|
| 57 | + $this->grid->addDragHandler()->onReorder(function($order) { |
|
| 58 | 58 | $result = true; |
| 59 | 59 | foreach ($this->nodes()->get() as $node) { |
| 60 | 60 | $node->position = array_search($node->id, $order); |
@@ -62,14 +62,14 @@ discard block |
||
| 62 | 62 | $result &= $node->save(); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - $notifier = $result? $this->notify(__('Items reordered!')): $this->notifyError(__('Error saving order!')); |
|
| 65 | + $notifier = $result ? $this->notify(__('Items reordered!')) : $this->notifyError(__('Error saving order!')); |
|
| 66 | 66 | |
| 67 | 67 | return $this->grid->jsSave($notifier); |
| 68 | 68 | }); |
| 69 | 69 | |
| 70 | 70 | $this->addContolButton('update', $this->getUpdateModal(), 'edit'); |
| 71 | 71 | |
| 72 | - $this->addContolButton('delete', function ($jschain, $id) { |
|
| 72 | + $this->addContolButton('delete', function($jschain, $id) { |
|
| 73 | 73 | CommonData::find($id)->delete(); |
| 74 | 74 | |
| 75 | 75 | return $jschain->closest('tr')->transition('fade left'); |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | $ret .= $button->getHtml(); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - return $ret;; |
|
| 94 | + return $ret; ; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | public function getUpdateModal() |
@@ -100,9 +100,9 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | $grid->pageUpdate = $grid->add($grid->pageUpdate ?: $grid->pageDefault, ['short_name'=>'edit']); |
| 102 | 102 | |
| 103 | - $modal = new jsModal(__('Edit'), $grid->pageUpdate, [$grid->name => $grid->jsRow()->data('id'), $grid->name.'_sort' => $grid->getSortBy()]); |
|
| 103 | + $modal = new jsModal(__('Edit'), $grid->pageUpdate, [$grid->name => $grid->jsRow()->data('id'), $grid->name . '_sort' => $grid->getSortBy()]); |
|
| 104 | 104 | |
| 105 | - $grid->pageUpdate->set(function () { |
|
| 105 | + $grid->pageUpdate->set(function() { |
|
| 106 | 106 | $grid = $this->grid; |
| 107 | 107 | |
| 108 | 108 | $grid->model->load($grid->app->stickyGet($grid->name)); |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | // set save handler with reload trigger |
| 122 | 122 | // adds default submit hook if it is not already set for this form |
| 123 | 123 | if (!$grid->formUpdate->hookHasCallbacks('submit')) { |
| 124 | - $grid->formUpdate->onSubmit(function ($form) { |
|
| 124 | + $grid->formUpdate->onSubmit(function($form) { |
|
| 125 | 125 | $form->model->save(); |
| 126 | 126 | |
| 127 | 127 | return $this->grid->jsSaveUpdate(); |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | $this->grid->on('click', ".$class", $callback, [$this->grid->table->jsRow()->data('id')]); |
| 140 | 140 | |
| 141 | - $this->buttons[$name] = new \atk4\ui\Button($icon? compact('icon'): $name); |
|
| 141 | + $this->buttons[$name] = new \atk4\ui\Button($icon ? compact('icon') : $name); |
|
| 142 | 142 | |
| 143 | 143 | $this->buttons[$name]->app = $this->app; |
| 144 | 144 | |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | |
| 166 | 166 | $rowsEmpty = []; |
| 167 | 167 | |
| 168 | - $model = new \atk4\data\Model($rows? new \atk4\data\Persistence_Static($rows): new \atk4\data\Persistence_Array($rowsEmpty)); |
|
| 168 | + $model = new \atk4\data\Model($rows ? new \atk4\data\Persistence_Static($rows) : new \atk4\data\Persistence_Array($rowsEmpty)); |
|
| 169 | 169 | |
| 170 | 170 | $captions = [ |
| 171 | 171 | 'position' => __('Position'), |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | ]; |
| 176 | 176 | |
| 177 | 177 | foreach ($captions as $key => $caption) { |
| 178 | - $field = $rows? $model->hasField($key): $model->addField($key); |
|
| 178 | + $field = $rows ? $model->hasField($key) : $model->addField($key); |
|
| 179 | 179 | |
| 180 | 180 | if ($key === 'readonly') { |
| 181 | 181 | $field->setDefaults(['ui' => ['visible' => false]]); |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | |
| 192 | 192 | public function getNodeForm() |
| 193 | 193 | { |
| 194 | - if (! $this->form) { |
|
| 194 | + if (!$this->form) { |
|
| 195 | 195 | $this->form = new Form(['buttonSave' => ['Button', __('Save'), 'primary']]); |
| 196 | 196 | |
| 197 | 197 | $this->form->addHook('submit', function($form) { |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | |
| 206 | 206 | CommonData::create(array_merge($values, [ |
| 207 | 207 | 'position' => $this->nodes()->max('position') + 1 |
| 208 | - ]), $this->parentId? CommonData::find($this->parentId): null); |
|
| 208 | + ]), $this->parentId ? CommonData::find($this->parentId) : null); |
|
| 209 | 209 | |
| 210 | 210 | return $this->grid->jsSaveCreate(); |
| 211 | 211 | }); |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | final public static function getActionUrls($meta, $accessParams = []) |
| 51 | 51 | { |
| 52 | - $id = is_numeric($meta)? $meta: $meta->id; |
|
| 52 | + $id = is_numeric($meta) ? $meta : $meta->id; |
|
| 53 | 53 | |
| 54 | 54 | $urls = []; |
| 55 | 55 | foreach (static::$allowedActions as $action) { |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | final protected function hasUserAccess() |
| 68 | 68 | { |
| 69 | - return $this->forUsersOnly? (bool) Auth::id(): true; |
|
| 69 | + return $this->forUsersOnly ? (bool) Auth::id() : true; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |