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

View File

@@ -155,14 +155,7 @@ class Controller extends ExController
$this->authorize('delete', 'categories');
$category = Category::findOrFail($category);
if (is_file($category->image)) {
unlink($category->image);
}
// delete image from s3
if (env('FILESYSTEM_DISK') == 's3') {
Storage::disk('s3')->delete($category->image);
}
Storage::delete($category->image);
$category->delete();
$this->info(trans('admin.messages.deleted'));

View File

@@ -10,7 +10,6 @@ use App\Http\Requests\Dashboard\Partner\Store as StoreRequest;
use App\Jobs\Dashboard\Partner\Store as StoreJob;
use App\Jobs\Dashboard\Partner\Update as UpdateJob;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Storage;
class Controller extends ExController
@@ -48,19 +47,8 @@ class Controller extends ExController
public function update(UpdateRequest $request, Partner $partner)
{
if ($request->hasFile('image')) {
if (env('FILESYSTEM_DISK') == 's3') {
// delete old image from s3
Storage::disk('s3')->delete($partner->image);
} else {
// detele old image
$imagePath = public_path($partner->image);
if (File::exists($imagePath)) {
File::delete($imagePath);
}
}
$path = $request->file('image')->store('uploads/partners');
Storage::delete($partner->image);
$path = $request->file('image')->store('uploads/partners');
} else {
$path = $partner->image;
}
@@ -75,17 +63,7 @@ class Controller extends ExController
{
$this->authorize('delete', 'partners');
if (env('FILESYSTEM_DISK') == 's3') {
// delete old image from s3
Storage::disk('s3')->delete($partner->image);
} else {
$imagePath = public_path($partner->image);
if (File::exists($imagePath)) {
File::delete($imagePath);
}
}
Storage::delete($partner->image);
$partner->delete();
$this->info(trans('admin.messages.deleted'));

View File

@@ -57,14 +57,8 @@ class Controller extends ExController
}
if ($request->hasFile('image')) {
if (env('FILESYSTEM_DISK') == 's3') {
Storage::disk('s3')->delete($post->image);
} else {
if (is_file($post->image)) {
unlink($post->image);
}
}
$path = $request->file('image')->store('uploads/posts');
Storage::delete($post->image);
$path = $request->file('image')->store('uploads/posts');
} else {
$path = $post->image;
}
@@ -122,14 +116,7 @@ class Controller extends ExController
public function delete(Post $post)
{
$this->authorize('delete', 'posts');
if (env('FILESYSTEM_DISK') == 's3') {
Storage::disk('s3')->delete($post->image);
} else {
if (is_file($post->image)) {
unlink($post->image);
}
}
Storage::delete($post->image);
$post->delete();
$this->info(trans('admin.messages.deleted'));
return redirect()->back();

View File

@@ -10,7 +10,6 @@ use App\Jobs\Dashboard\Service\Store as StoreJob;
use App\Jobs\Dashboard\Service\Update as UpdateJob;
use App\Models\Problem;
use App\Models\ServiceProblem;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Storage;
class Controller extends ExController
@@ -62,18 +61,8 @@ class Controller extends ExController
public function update(UpdateRequest $request, Service $service)
{
if ($request->hasFile('image')) {
if (env('FILESYSTEM_DISK') == 's3') {
$imagePath = $service->image;
Storage::disk('s3')->delete($imagePath);
} else {
$imagePath = public_path($service->image);
if (File::exists($imagePath)) {
File::delete($imagePath);
}
}
$path = $request->file('image')->store('uploads/services');
Storage::delete($service->image);
$path = $request->file('image')->store('uploads/services');
} else {
$path = $service->image;
}
@@ -106,17 +95,7 @@ class Controller extends ExController
{
$this->authorize('delete', 'services');
if (env('FILESYSTEM_DISK') == 's3') {
$imagePath = $service->image;
Storage::disk('s3')->delete($imagePath);
} else {
$imagePath = public_path($service->image);
if (File::exists($imagePath)) {
File::delete($imagePath);
}
}
Storage::delete($service->image);
ServiceProblem::where('service_id', $service->id)->delete();
$service->delete();

View File

@@ -49,18 +49,8 @@ class Controller extends ExController
public function update(UpdateRequest $request, UsefulInfo $usefulinfo)
{
if ($request->hasFile('image')) {
if (env('FILESYSTEM_DISK') == 's3') {
$imagePath = $usefulinfo->image;
Storage::disk('s3')->delete($imagePath);
} else {
$imagePath = public_path($usefulinfo->image);
if (File::exists($imagePath)) {
File::delete($imagePath);
}
}
$path = $request->file('image')->store('uploads/usefulinfos');
Storage::delete($usefulinfo->image);
$path = $request->file('image')->store('uploads/usefulinfos');
} else {
$path = $usefulinfo->image;
}
@@ -84,17 +74,7 @@ class Controller extends ExController
$item->delete();
}
if (env('FILESYSTEM_DISK') == 's3') {
$imagePath = $usefulinfo->image;
Storage::disk('s3')->delete($imagePath);
} else {
$imagePath = public_path($usefulinfo->image);
if (File::exists($imagePath)) {
File::delete($imagePath);
}
}
Storage::delete($usefulinfo->image);
$usefulinfo->delete();
$this->info(trans('admin.messages.deleted'));