@@ -22,24 +22,24 @@ |
||
| 22 | 22 | public function handle(Request $request) |
| 23 | 23 | { |
| 24 | 24 | // Strict protection enabled: we won't remove assets who are still being used... |
| 25 | - $assetIds = collect($request->input('asset_ids', []))->reject(function($assetId){ |
|
| 25 | + $assetIds = collect($request->input('asset_ids', []))->reject(function($assetId) { |
|
| 26 | 26 | return DB::table('asset_pivots') |
| 27 | 27 | ->where('asset_id', $assetId) |
| 28 | 28 | ->where('unused', 0) |
| 29 | 29 | ->exists(); |
| 30 | 30 | })->toArray(); |
| 31 | 31 | |
| 32 | - if($assetIds) |
|
| 32 | + if ($assetIds) |
|
| 33 | 33 | { |
| 34 | - foreach($assetIds as $k => $assetId) { |
|
| 35 | - try{ |
|
| 34 | + foreach ($assetIds as $k => $assetId) { |
|
| 35 | + try { |
|
| 36 | 36 | $this->deleteAsset->remove($assetId); |
| 37 | - } catch(FileNotAccessibleException $e) { |
|
| 37 | + } catch (FileNotAccessibleException $e) { |
|
| 38 | 38 | unset($assetIds[$k]); // So our count of removed assets is correct in the log. |
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - Audit::activity()->log('removed ' . count($assetIds) . ' assets from the mediagallery.'); |
|
| 42 | + Audit::activity()->log('removed '.count($assetIds).' assets from the mediagallery.'); |
|
| 43 | 43 | |
| 44 | 44 | return true; |
| 45 | 45 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | public function handle(string $filename, Request $request) |
| 19 | 19 | { |
| 20 | - $assets = Asset::whereIn('id', (array) $request->input('asset_ids', []))->get(); |
|
| 20 | + $assets = Asset::whereIn('id', (array)$request->input('asset_ids', []))->get(); |
|
| 21 | 21 | |
| 22 | 22 | // enable output of HTTP headers TODO: this should be moved to the controller instead... |
| 23 | 23 | $options = new Archive(); |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | $zip = new ZipStream($filename, $options); |
| 27 | 27 | |
| 28 | 28 | $assets->each(function(Asset $asset) use($zip){ |
| 29 | - if(file_exists($asset->getFirstMediaPath())) { |
|
| 29 | + if (file_exists($asset->getFirstMediaPath())) { |
|
| 30 | 30 | $zip->addFileFromPath($asset->filename(), $asset->getFirstMediaPath()); |
| 31 | 31 | } |
| 32 | 32 | }); |
@@ -21,13 +21,13 @@ discard block |
||
| 21 | 21 | $assets = Asset::with('media')->orderBy('created_at', 'DESC')->select('assets.*'); |
| 22 | 22 | |
| 23 | 23 | if ($search) { |
| 24 | - $assets->whereHas('media', function (Builder $query) use ($search) { |
|
| 25 | - $query->where('file_name', 'LIKE', '%' . $search . '%'); |
|
| 24 | + $assets->whereHas('media', function(Builder $query) use ($search) { |
|
| 25 | + $query->where('file_name', 'LIKE', '%'.$search.'%'); |
|
| 26 | 26 | }); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | if ($unused) { |
| 30 | - $assets->whereNotExists(function ($query) { |
|
| 30 | + $assets->whereNotExists(function($query) { |
|
| 31 | 31 | $query->select(DB::raw(1)) |
| 32 | 32 | ->from('asset_pivots') |
| 33 | 33 | ->whereRaw('asset_pivots.asset_id = assets.id') |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | }); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - if($owner){ |
|
| 38 | + if ($owner) { |
|
| 39 | 39 | $owner = ModelReference::fromString($owner)->instance(); |
| 40 | 40 | $modelAssets = collect(); |
| 41 | 41 | $modelAssets = $modelAssets->merge($owner->assets()); |
@@ -24,18 +24,18 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | public function bulk(Request $request) |
| 26 | 26 | { |
| 27 | - if($request->input('type') == 'download') { |
|
| 27 | + if ($request->input('type') == 'download') { |
|
| 28 | 28 | return $this->download($request); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - if($request->input('type') == 'remove') { |
|
| 31 | + if ($request->input('type') == 'remove') { |
|
| 32 | 32 | return $this->remove($request); |
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | private function download(Request $request) |
| 37 | 37 | { |
| 38 | - $filename = Str::slug(config('app.name')) . '_assets_' . date('YmdHis') . '.zip'; |
|
| 38 | + $filename = Str::slug(config('app.name')).'_assets_'.date('YmdHis').'.zip'; |
|
| 39 | 39 | |
| 40 | 40 | // TODO: do the response here instead of the zip action itself |
| 41 | 41 | return $this->zipAction->handle($filename, $request); |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | { |
| 46 | 46 | $result = $this->removalAction->handle($request); |
| 47 | 47 | |
| 48 | - if($result) { |
|
| 48 | + if ($result) { |
|
| 49 | 49 | return redirect()->back()->with('messages.success', 'De mediabestanden zijn verwijderd'); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -29,12 +29,12 @@ |
||
| 29 | 29 | |
| 30 | 30 | public function icon(): string |
| 31 | 31 | { |
| 32 | - if(isset($this->mapping[$this->mimetype])) { |
|
| 32 | + if (isset($this->mapping[$this->mimetype])) { |
|
| 33 | 33 | return $this->mapping[$this->mimetype]; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - foreach($this->mapping as $mimetype => $icon) { |
|
| 37 | - if(Str::contains($this->mimetype, $mimetype)) { |
|
| 36 | + foreach ($this->mapping as $mimetype => $icon) { |
|
| 37 | + if (Str::contains($this->mimetype, $mimetype)) { |
|
| 38 | 38 | return $icon; |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | public function untagged(): self |
| 32 | 32 | { |
| 33 | - $filteredItems = array_filter($this->items, function(NavItem $navItem){ |
|
| 33 | + $filteredItems = array_filter($this->items, function(NavItem $navItem) { |
|
| 34 | 34 | return $navItem->isUntagged(); |
| 35 | 35 | }); |
| 36 | 36 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | { |
| 42 | 42 | $instance = new static(); |
| 43 | 43 | |
| 44 | - foreach($navItems as $item) { |
|
| 44 | + foreach ($navItems as $item) { |
|
| 45 | 45 | $instance->add($item); |
| 46 | 46 | } |
| 47 | 47 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | public function isTagged($tags): bool |
| 33 | 33 | { |
| 34 | - return count(array_intersect($this->tags, (array) $tags)) > 0; |
|
| 34 | + return count(array_intersect($this->tags, (array)$tags)) > 0; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | public function isUntagged(): bool |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | public function render(): string |
| 43 | 43 | { |
| 44 | - $output = '<a class="' . (isActiveUrl($this->url()) ? 'active' : '') . '" href="' . $this->url() . '">'; |
|
| 44 | + $output = '<a class="'.(isActiveUrl($this->url()) ? 'active' : '').'" href="'.$this->url().'">'; |
|
| 45 | 45 | $output .= ucfirst($this->label()); |
| 46 | 46 | $output .= '</a>'; |
| 47 | 47 | |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | { |
| 55 | 55 | foreach ($modelReferences as $locale => $modelReferenceString) { |
| 56 | 56 | if (!$modelReferenceString) { |
| 57 | - throw new \InvalidArgumentException('Homepage setting value cannot be empty. Value for locale ' . $locale . ' is missing.'); |
|
| 57 | + throw new \InvalidArgumentException('Homepage setting value cannot be empty. Value for locale '.$locale.' is missing.'); |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | } |
@@ -51,8 +51,8 @@ |
||
| 51 | 51 | |
| 52 | 52 | public function editFields(): Fields |
| 53 | 53 | { |
| 54 | - return $this->fields()->map(function (Field $field) { |
|
| 55 | - return $field->valueResolver(function ($model = null, $locale = null, $field) { |
|
| 54 | + return $this->fields()->map(function(Field $field) { |
|
| 55 | + return $field->valueResolver(function($model = null, $locale = null, $field) { |
|
| 56 | 56 | return $this->settings->get($field->getKey(), $locale); |
| 57 | 57 | }); |
| 58 | 58 | }); |