test
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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'));
|
||||
|
||||
@@ -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'));
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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'));
|
||||
|
||||
@@ -43,20 +43,8 @@ class Update extends FormRequest
|
||||
public function getImage(Category $category): string
|
||||
{
|
||||
if ($this->hasFile('image')) {
|
||||
if (env('FILESYSTEM_DISK') == 's3') {
|
||||
// delete old image from s3
|
||||
Storage::disk('s3')->delete($category->image);
|
||||
|
||||
$folder = "uploads/categories";
|
||||
|
||||
return (string) $this->file('image')->store($folder);
|
||||
} else {
|
||||
// detele old image
|
||||
if (is_file($category->image)) {
|
||||
unlink($category->image);
|
||||
}
|
||||
return $this->file('image')->store('uploads/categories', 'local');
|
||||
}
|
||||
Storage::delete($category->image);
|
||||
return (string) $this->file('image')->store('uploads/categories');
|
||||
} else {
|
||||
return 'null';
|
||||
}
|
||||
|
||||
@@ -63,15 +63,7 @@ class Update extends FormRequest
|
||||
public function getPoster(Product $product): string
|
||||
{
|
||||
if ($this->hasFile('poster')) {
|
||||
if (env('FILESYSTEM_DISK') == 's3') {
|
||||
// delete old file from s3
|
||||
Storage::disk('s3')->delete($product->poster);
|
||||
} else {
|
||||
// delete old file
|
||||
$oldPath = public_path($product->poster);
|
||||
if (is_file($oldPath)) unlink($oldPath);
|
||||
}
|
||||
|
||||
Storage::delete($product->poster);
|
||||
$folder = "uploads/posters/" . Carbon::now()->format('Y/m/d');
|
||||
return (string) $this->file('poster')->store($folder);
|
||||
}
|
||||
@@ -85,13 +77,9 @@ class Update extends FormRequest
|
||||
public function getCalc(Product $product): string|null
|
||||
{
|
||||
if ($this->hasFile('calc')) {
|
||||
if (env('FILESYSTEM_DISK') == 's3' and $product->calc) {
|
||||
// delete old file from s3
|
||||
Storage::disk('s3')->delete($product->calc);
|
||||
} elseif($product->calc) {
|
||||
unlink($product->calc);
|
||||
if ($product->calc) {
|
||||
Storage::delete($product->calc);
|
||||
}
|
||||
|
||||
$folder = "uploads/calc/" . Carbon::now()->format('Y/m/d');
|
||||
return (string) $this->file('calc')->store($folder);
|
||||
}
|
||||
@@ -101,11 +89,9 @@ class Update extends FormRequest
|
||||
public function getDataSheet(Product $product)
|
||||
{
|
||||
if ($this->hasFile('data_sheet')) {
|
||||
|
||||
if (is_file($this->get('data_sheet'))) {
|
||||
unlink($this->get("data_sheet"));
|
||||
if ($product->data_sheet) {
|
||||
Storage::delete($product->data_sheet);
|
||||
}
|
||||
|
||||
$folder = "uploads/datasheet/" . Carbon::now()->format('Y/m/d');
|
||||
return (string) $this->file('data_sheet')->store($folder);
|
||||
}
|
||||
@@ -119,18 +105,8 @@ class Update extends FormRequest
|
||||
public function getPosterThumb(Product $product): string
|
||||
{
|
||||
if ($this->hasFile('poster')) {
|
||||
if (env('FILESYSTEM_DISK') == 's3') {
|
||||
// delete old file from s3
|
||||
Storage::disk('s3')->delete($product->poster_thumb);
|
||||
} else {
|
||||
// delete old file local
|
||||
$oldPath = public_path($product->poster_thumb);
|
||||
if (is_file($oldPath)) unlink($oldPath);
|
||||
}
|
||||
|
||||
$image = $this->file('poster');
|
||||
$tempPath = $image->store('temp', 'public');
|
||||
|
||||
Storage::delete($product->poster_thumb);
|
||||
$tempPath = $this->file('poster')->store('temp', 'public');
|
||||
$resizer = new ImageResize();
|
||||
return $resizer->resize($tempPath, 322, 'posters', true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user