Skip to content

Commit

Permalink
Merge pull request #1 from tomatophp/develop
Browse files Browse the repository at this point in the history
fix upload image on setting
  • Loading branch information
3x1io authored Jan 26, 2024
2 parents ecf30d6 + 89c96fc commit 525b84e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Services/Setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Str;
use ProtoneMedia\Splade\Facades\Toast;
Expand Down Expand Up @@ -60,6 +61,11 @@ public function save(FormRequest $request, string $redirect, array|null $media=
//Save Media
foreach ($media as $item) {
if ($request->hasFile($item)) {
$filePath = storage_path('public/settings/'. $item . '.'.$request->file($item)->extension());
$checkIfExist = File::exists($filePath);
if($checkIfExist){
File::delete($filePath);
}
$request->file($item)->storeAs('public/settings', $item . '.'.$request->file($item)->extension());
$setting->{$item} = url('storage/settings/'.$item .'.'.$request->file($item)->extension());
}
Expand Down

0 comments on commit 525b84e

Please sign in to comment.