This commit is contained in:
2026-04-16 11:25:40 +05:00
parent 2ba5677c45
commit 3aa4601229
13 changed files with 80 additions and 234 deletions

View File

@@ -54,17 +54,8 @@ class Controller extends ExController
}
if ($request->hasFile('image')) {
if (env('FILESYSTEM_DISK') == 's3') {
// delete old image from s3
Storage::disk('s3')->delete($brand->image);
$path = $this->storeImageToS3($request->file('image'));
} else {
// detele old image
if (is_file($brand->image)) {
unlink($brand->image);
}
$path = $request->file('image')->store('uploads/brands');
}
Storage::delete($brand->image);
$path = $this->storeImageToS3($request->file('image'));
} else {
$path = $brand->image;
}
@@ -87,12 +78,7 @@ class Controller extends ExController
}
if ($request->hasFile('image')) {
$file = $request->file('image');
if (env('FILESYSTEM_DISK') == 's3') {
$path = $this->storeImageToS3($file);
} else {
$path = $file->store('uploads/brands');
}
$path = $this->storeImageToS3($request->file('image'));
}
$this->dispatchSync(StoreJob::fromRequest($request, $path));
@@ -109,14 +95,7 @@ class Controller extends ExController
{
$this->authorize('delete', 'brands');
if (is_file($brand->image)) {
unlink($brand->image);
}
// delete image from s3
if (env('FILESYSTEM_DISK') == 's3') {
Storage::disk('s3')->delete($brand->image);
}
Storage::delete($brand->image);
Product::where('brand_id', $brand->id)->withTrashed()->update([
'brand_id' => null