Skip to content

Commit

Permalink
hotifx/persist-banner-image (#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-inamdar authored May 22, 2020
1 parent 57a8320 commit a7d4419
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/Http/Controllers/Core/V1/SettingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\Http\Controllers\Controller;
use App\Http\Requests\Setting\IndexRequest;
use App\Http\Requests\Setting\UpdateRequest;
use App\Models\File;
use App\Models\Setting;
use Illuminate\Support\Facades\DB;

Expand Down Expand Up @@ -96,6 +97,18 @@ public function update(UpdateRequest $request)
],
]);

if ($request->filled('cms.frontend.banner.image_file_id')) {
/** @var \App\Models\File $file */
$file = File::query()
->findOrFail($request->input('cms.frontend.banner.image_file_id'))
->assigned();

// Create resized version for common dimensions.
foreach (config('ck.cached_image_dimensions') as $maxDimension) {
$file->resizedVersion($maxDimension);
}
}

event(EndpointHit::onUpdate($request, 'Updated settings'));

return new Setting();
Expand Down

0 comments on commit a7d4419

Please sign in to comment.