diff --git a/Modules/Core/Console/Installers/Scripts/SetAppKey.php b/Modules/Core/Console/Installers/Scripts/SetAppKey.php index 9b2e57f85..167a933e3 100644 --- a/Modules/Core/Console/Installers/Scripts/SetAppKey.php +++ b/Modules/Core/Console/Installers/Scripts/SetAppKey.php @@ -3,8 +3,8 @@ namespace Modules\Core\Console\Installers\Scripts; use Illuminate\Console\Command; -use Illuminate\Encryption\Encrypter; use Illuminate\Console\ConfirmableTrait; +use Illuminate\Encryption\Encrypter; use Modules\Core\Console\Installers\SetupScript; class SetAppKey implements SetupScript @@ -40,7 +40,7 @@ public function fire(Command $command) */ protected function generateRandomKey() { - return 'base64:'.base64_encode( + return 'base64:' . base64_encode( Encrypter::generateKey(config('app.cipher')) ); } @@ -74,7 +74,7 @@ protected function writeNewEnvironmentFileWith($key) { file_put_contents(app()->environmentFilePath(), preg_replace( $this->keyReplacementPattern(), - 'APP_KEY='.$key, + 'APP_KEY=' . $key, file_get_contents(app()->environmentFilePath()) )); } @@ -86,7 +86,7 @@ protected function writeNewEnvironmentFileWith($key) */ protected function keyReplacementPattern() { - $escaped = preg_quote('='.config('app.key'), '/'); + $escaped = preg_quote('=' . config('app.key'), '/'); return "/^APP_KEY{$escaped}/m"; } diff --git a/Modules/Media/Events/Handlers/MoveFileOnDisk.php b/Modules/Media/Events/Handlers/MoveFileOnDisk.php index d8f5ed8bd..d494510ad 100644 --- a/Modules/Media/Events/Handlers/MoveFileOnDisk.php +++ b/Modules/Media/Events/Handlers/MoveFileOnDisk.php @@ -50,7 +50,7 @@ private function moveThumbnails($event) $fromPath = $this->getFilenameFor($event->previousData['path'], $thumbnail); $toPath = $this->getFilenameFor($event->file->path, $thumbnail); - $this->move($fromPath, $toPath); + $this->move($fromPath, $toPath); } } diff --git a/Modules/Media/Http/Controllers/Frontend/MediaController.php b/Modules/Media/Http/Controllers/Frontend/MediaController.php index 39dd2fa1c..acaf1cdbd 100644 --- a/Modules/Media/Http/Controllers/Frontend/MediaController.php +++ b/Modules/Media/Http/Controllers/Frontend/MediaController.php @@ -3,7 +3,6 @@ namespace Modules\Media\Http\Controllers\Frontend; use Illuminate\Routing\Controller; -use Illuminate\Support\Facades\Storage; use Intervention\Image\Facades\Image; use Modules\Media\Repositories\FileRepository; @@ -29,7 +28,7 @@ public function show($path) return Image::make($path)->response(); return response()->file($path, [ - "Content-Type:$type" + "Content-Type:$type", ]); } } diff --git a/Modules/Media/Http/Requests/UploadDropzoneMediaRequest.php b/Modules/Media/Http/Requests/UploadDropzoneMediaRequest.php index 376fbdd92..72170215e 100644 --- a/Modules/Media/Http/Requests/UploadDropzoneMediaRequest.php +++ b/Modules/Media/Http/Requests/UploadDropzoneMediaRequest.php @@ -27,7 +27,7 @@ public function messages() $size = $this->getMaxFileSize(); return [ - 'file.max' => trans('media::media.file too large', ['size' => $size]) + 'file.max' => trans('media::media.file too large', ['size' => $size]), ]; } diff --git a/Modules/Media/Http/Requests/UploadMediaRequest.php b/Modules/Media/Http/Requests/UploadMediaRequest.php index b729e296c..c2236bb45 100644 --- a/Modules/Media/Http/Requests/UploadMediaRequest.php +++ b/Modules/Media/Http/Requests/UploadMediaRequest.php @@ -27,7 +27,7 @@ public function messages() $size = $this->getMaxFileSize(); return [ - 'file.max' => trans('media::media.file too large', ['size' => $size]) + 'file.max' => trans('media::media.file too large', ['size' => $size]), ]; } diff --git a/Modules/Media/Providers/MediaServiceProvider.php b/Modules/Media/Providers/MediaServiceProvider.php index c3a66abb1..3643e1d0b 100644 --- a/Modules/Media/Providers/MediaServiceProvider.php +++ b/Modules/Media/Providers/MediaServiceProvider.php @@ -14,13 +14,13 @@ use Modules\Media\Contracts\DeletingMedia; use Modules\Media\Contracts\StoringMedia; use Modules\Media\Entities\File; +use Modules\Media\Events\FileStartedMoving; use Modules\Media\Events\FolderIsDeleting; use Modules\Media\Events\FolderWasCreated; use Modules\Media\Events\FolderWasUpdated; use Modules\Media\Events\Handlers\CreateFolderOnDisk; use Modules\Media\Events\Handlers\DeleteAllChildrenOfFolder; use Modules\Media\Events\Handlers\DeleteFolderOnDisk; -use Modules\Media\Events\FileStartedMoving; use Modules\Media\Events\Handlers\HandleMediaStorage; use Modules\Media\Events\Handlers\MoveFileOnDisk; use Modules\Media\Events\Handlers\RegisterMediaSidebar; diff --git a/Modules/Media/Support/Collection/NestedFoldersCollection.php b/Modules/Media/Support/Collection/NestedFoldersCollection.php index c97c8f5b0..b338f58d0 100644 --- a/Modules/Media/Support/Collection/NestedFoldersCollection.php +++ b/Modules/Media/Support/Collection/NestedFoldersCollection.php @@ -26,7 +26,7 @@ public function __construct($items = []) public function nest() { $parentColumn = $this->parentColumn; - if ( ! $parentColumn) { + if (! $parentColumn) { return $this; } // Set id as keys. @@ -34,7 +34,7 @@ public function nest() $keysToDelete = []; // Add empty collection to each items. $collection = $this->each(function ($item) { - if ( ! $item->items) { + if (! $item->items) { $item->items = app(BaseCollection::class); } }); @@ -43,6 +43,7 @@ public function nest() $collection = $this->reject(function ($item) use ($parentColumn) { if ($item->$parentColumn) { $missingAncestor = $this->anAncestorIsMissing($item); + return $missingAncestor; } }); @@ -56,6 +57,7 @@ public function nest() } // Delete moved items. $this->items = array_values(array_except($collection->items, $keysToDelete)); + return $this; } @@ -71,7 +73,11 @@ public function nest() * @return array */ public function listsFlattened( - $column = 'title', BaseCollection $collection = null, $level = 0, array &$flattened = [], $indentChars = null, + $column = 'title', + BaseCollection $collection = null, + $level = 0, + array &$flattened = [], + $indentChars = null, $parent_string = null ) { $collection = $collection ?: $this; @@ -84,10 +90,17 @@ public function listsFlattened( } $flattened[$item->id] = $item_string; if ($item->items) { - $this->listsFlattened($column, $item->items, $level + 1, $flattened, $indentChars, - ($parent_string) ? $item_string : null); + $this->listsFlattened( + $column, + $item->items, + $level + 1, + $flattened, + $indentChars, + ($parent_string) ? $item_string : null + ); } } + return $flattened; } @@ -101,7 +114,11 @@ public function listsFlattened( * @return array */ public function listsFlattenedQualified( - $column = 'title', BaseCollection $collection = null, $level = 0, array &$flattened = [], $indentChars = null + $column = 'title', + BaseCollection $collection = null, + $level = 0, + array &$flattened = [], + $indentChars = null ) { return $this->listsFlattened($column, $collection, $level, $flattened, $indentChars, true); } @@ -114,6 +131,7 @@ public function listsFlattenedQualified( public function setIndent(string $indentChars) { $this->indentChars = $indentChars; + return $this; } @@ -124,6 +142,7 @@ public function setIndent(string $indentChars) public function noCleaning() { $this->removeItemsWithMissingAncestor = false; + return $this; } @@ -135,13 +154,14 @@ public function noCleaning() public function anAncestorIsMissing($item) { $parentColumn = $this->parentColumn; - if ( ! $item->$parentColumn) { + if (! $item->$parentColumn) { return false; } - if ( ! $this->has($item->$parentColumn)) { + if (! $this->has($item->$parentColumn)) { return true; } $parent = $this[$item->$parentColumn]; + return $this->anAncestorIsMissing($parent); } diff --git a/Modules/Translation/Resources/lang/media/en/media.php b/Modules/Translation/Resources/lang/media/en/media.php index 2734a00db..d557c9dc1 100644 --- a/Modules/Translation/Resources/lang/media/en/media.php +++ b/Modules/Translation/Resources/lang/media/en/media.php @@ -38,5 +38,5 @@ 'create resource' => 'Create media', 'edit resource' => 'Edit media', 'destroy resource' => 'Delete media', - 'file too large' => 'File is too large. Must be below :size MB.' + 'file too large' => 'File is too large. Must be below :size MB.', ];