storage url o'zgartirildi
This commit is contained in:
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Api;
|
namespace App\Api;
|
||||||
|
|
||||||
|
use App\Support\Uploads;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Support\Facades\Storage;
|
|
||||||
use Intervention\Image\Facades\Image as Imagee;
|
use Intervention\Image\Facades\Image as Imagee;
|
||||||
|
|
||||||
class ImageResize
|
class ImageResize
|
||||||
@@ -54,8 +54,8 @@ class ImageResize
|
|||||||
// 3. Upload thumb to S3/MinIO
|
// 3. Upload thumb to S3/MinIO
|
||||||
$thumbKey = $this->thumbFolder($type) . '/' . $thumbFilename;
|
$thumbKey = $this->thumbFolder($type) . '/' . $thumbFilename;
|
||||||
|
|
||||||
if (env('FILESYSTEM_DISK') === 's3') {
|
if (config('filesystems.default') === 's3') {
|
||||||
Storage::disk('s3')->put($thumbKey, file_get_contents($tmpThumb));
|
Uploads::put($thumbKey, file_get_contents($tmpThumb), 's3');
|
||||||
} else {
|
} else {
|
||||||
// Local: move to public/uploads/…/thumbs/…
|
// Local: move to public/uploads/…/thumbs/…
|
||||||
$localDir = public_path(dirname($thumbKey));
|
$localDir = public_path(dirname($thumbKey));
|
||||||
|
|||||||
@@ -100,12 +100,19 @@ class Controller extends ExController
|
|||||||
return view('dashboard.products.store', compact('categories', 'brands', 'colors', 'measurement'));
|
return view('dashboard.products.store', compact('categories', 'brands', 'colors', 'measurement'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$product = $this->dispatchSync(StoreJob::fromRequest($request));
|
try {
|
||||||
|
$product = $this->dispatchSync(StoreJob::fromRequest($request));
|
||||||
|
|
||||||
$product->categories()->attach([$request->getCategoryID()]);
|
$product->categories()->attach([$request->getCategoryID()]);
|
||||||
|
|
||||||
$this->charSync($product, $request->characteristics);
|
$this->charSync($product, $request->characteristics);
|
||||||
$this->dispatchSync(new ChildJob($request, $product));
|
$this->dispatchSync(new ChildJob($request, $product));
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return Response::json([
|
||||||
|
'status' => false,
|
||||||
|
'messages' => $e->getMessage()
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
|
||||||
$this->success(trans('admin.messages.created'));
|
$this->success(trans('admin.messages.created'));
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Http\Controllers\Dashboard\Slider;
|
namespace App\Http\Controllers\Dashboard\Slider;
|
||||||
|
|
||||||
use App\Models\Slider;
|
use App\Models\Slider;
|
||||||
|
use App\Support\Uploads;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Http\Controllers\Controller as ExController;
|
use App\Http\Controllers\Controller as ExController;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
@@ -53,7 +54,7 @@ class Controller extends ExController
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($request->hasFile('image')) {
|
if ($request->hasFile('image')) {
|
||||||
$path = $request->file('image')->store('uploads/sliders');
|
$path = Uploads::store($request->file('image'), 'uploads/sliders');
|
||||||
} else {
|
} else {
|
||||||
$path = $slider->image;
|
$path = $slider->image;
|
||||||
}
|
}
|
||||||
@@ -77,7 +78,7 @@ class Controller extends ExController
|
|||||||
|
|
||||||
|
|
||||||
if ($request->hasFile('image')) {
|
if ($request->hasFile('image')) {
|
||||||
$path = $request->file('image')->store('uploads/sliders');
|
$path = Uploads::store($request->file('image'), 'uploads/sliders');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->dispatchSync(StoreJob::fromRequest($request, $path));
|
$this->dispatchSync(StoreJob::fromRequest($request, $path));
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Http\Requests\Dashboard\Category;
|
namespace App\Http\Requests\Dashboard\Category;
|
||||||
|
|
||||||
|
use App\Support\Uploads;
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Illuminate\Support\Facades\Storage;
|
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class Request extends FormRequest
|
class Request extends FormRequest
|
||||||
@@ -44,9 +44,9 @@ class Request extends FormRequest
|
|||||||
if (env('FILESYSTEM_DISK') == 's3') {
|
if (env('FILESYSTEM_DISK') == 's3') {
|
||||||
$folder = "uploads/categories";
|
$folder = "uploads/categories";
|
||||||
|
|
||||||
return (string) $this->file('image')->store($folder);
|
return Uploads::store($this->file('image'), $folder);
|
||||||
} else {
|
} else {
|
||||||
return $this->file('image')->store('uploads/categories', 'local');
|
return Uploads::store($this->file('image'), 'uploads/categories', 'local');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return 'null';
|
return 'null';
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Http\Requests\Dashboard\Category;
|
namespace App\Http\Requests\Dashboard\Category;
|
||||||
|
|
||||||
use App\Models\Category;
|
use App\Models\Category;
|
||||||
|
use App\Support\Uploads;
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
@@ -44,7 +45,7 @@ class Update extends FormRequest
|
|||||||
{
|
{
|
||||||
if ($this->hasFile('image')) {
|
if ($this->hasFile('image')) {
|
||||||
Storage::delete($category->image);
|
Storage::delete($category->image);
|
||||||
return (string) $this->file('image')->store('uploads/categories');
|
return Uploads::store($this->file('image'), 'uploads/categories');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $category->image;
|
return $category->image;
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Http\Requests\Dashboard\Product;
|
namespace App\Http\Requests\Dashboard\Product;
|
||||||
|
|
||||||
|
use App\Support\Uploads;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Illuminate\Support\Facades\Storage;
|
|
||||||
use App\Api\ImageResize;
|
use App\Api\ImageResize;
|
||||||
|
|
||||||
class Store extends FormRequest
|
class Store extends FormRequest
|
||||||
@@ -71,7 +71,7 @@ class Store extends FormRequest
|
|||||||
{
|
{
|
||||||
$folder = "uploads/posters/" . Carbon::now()->format('Y/m/d');
|
$folder = "uploads/posters/" . Carbon::now()->format('Y/m/d');
|
||||||
|
|
||||||
return (string) $this->file('poster')->store($folder);
|
return Uploads::store($this->file('poster'), $folder);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -81,7 +81,7 @@ class Store extends FormRequest
|
|||||||
{
|
{
|
||||||
if ($this->hasFile('calc')) {
|
if ($this->hasFile('calc')) {
|
||||||
$folder = "uploads/calc/" . Carbon::now()->format('Y/m/d');
|
$folder = "uploads/calc/" . Carbon::now()->format('Y/m/d');
|
||||||
return (string) $this->file('calc')->store($folder);
|
return Uploads::store($this->file('calc'), $folder);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ class Store extends FormRequest
|
|||||||
{
|
{
|
||||||
if ($this->hasFile('data_sheet')) {
|
if ($this->hasFile('data_sheet')) {
|
||||||
$folder = "uploads/datasheet/" . Carbon::now()->format('Y/m/d');
|
$folder = "uploads/datasheet/" . Carbon::now()->format('Y/m/d');
|
||||||
return (string) $this->file('data_sheet')->store($folder);
|
return Uploads::store($this->file('data_sheet'), $folder);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@@ -102,7 +102,7 @@ class Store extends FormRequest
|
|||||||
public function getPosterThumb()
|
public function getPosterThumb()
|
||||||
{
|
{
|
||||||
$image = $this->file('poster');
|
$image = $this->file('poster');
|
||||||
$tempPath = $image->store('temp', 'public');
|
$tempPath = Uploads::store($image, 'temp', 'public');
|
||||||
|
|
||||||
$resizer = new ImageResize();
|
$resizer = new ImageResize();
|
||||||
return $resizer->resize($tempPath, 322, 'posters', true);
|
return $resizer->resize($tempPath, 322, 'posters', true);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Requests\Dashboard\Product;
|
namespace App\Http\Requests\Dashboard\Product;
|
||||||
|
|
||||||
|
use App\Support\Uploads;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
@@ -65,7 +66,7 @@ class Update extends FormRequest
|
|||||||
if ($this->hasFile('poster')) {
|
if ($this->hasFile('poster')) {
|
||||||
Storage::delete($product->poster);
|
Storage::delete($product->poster);
|
||||||
$folder = "uploads/posters/" . Carbon::now()->format('Y/m/d');
|
$folder = "uploads/posters/" . Carbon::now()->format('Y/m/d');
|
||||||
return (string) $this->file('poster')->store($folder);
|
return Uploads::store($this->file('poster'), $folder);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $product->poster;
|
return $product->poster;
|
||||||
@@ -81,7 +82,7 @@ class Update extends FormRequest
|
|||||||
Storage::delete($product->calc);
|
Storage::delete($product->calc);
|
||||||
}
|
}
|
||||||
$folder = "uploads/calc/" . Carbon::now()->format('Y/m/d');
|
$folder = "uploads/calc/" . Carbon::now()->format('Y/m/d');
|
||||||
return (string) $this->file('calc')->store($folder);
|
return Uploads::store($this->file('calc'), $folder);
|
||||||
}
|
}
|
||||||
return $product->calc;
|
return $product->calc;
|
||||||
}
|
}
|
||||||
@@ -93,7 +94,7 @@ class Update extends FormRequest
|
|||||||
Storage::delete($product->data_sheet);
|
Storage::delete($product->data_sheet);
|
||||||
}
|
}
|
||||||
$folder = "uploads/datasheet/" . Carbon::now()->format('Y/m/d');
|
$folder = "uploads/datasheet/" . Carbon::now()->format('Y/m/d');
|
||||||
return (string) $this->file('data_sheet')->store($folder);
|
return Uploads::store($this->file('data_sheet'), $folder);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $product->data_sheet;
|
return $product->data_sheet;
|
||||||
@@ -106,7 +107,7 @@ class Update extends FormRequest
|
|||||||
{
|
{
|
||||||
if ($this->hasFile('poster')) {
|
if ($this->hasFile('poster')) {
|
||||||
Storage::delete($product->poster_thumb);
|
Storage::delete($product->poster_thumb);
|
||||||
$tempPath = $this->file('poster')->store('temp', 'public');
|
$tempPath = Uploads::store($this->file('poster'), 'temp', 'public');
|
||||||
$resizer = new ImageResize();
|
$resizer = new ImageResize();
|
||||||
return $resizer->resize($tempPath, 322, 'posters', true);
|
return $resizer->resize($tempPath, 322, 'posters', true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace App\Jobs\Dashboard\Product;
|
|||||||
|
|
||||||
use App\Models\Product;
|
use App\Models\Product;
|
||||||
use App\Models\Screen;
|
use App\Models\Screen;
|
||||||
|
use App\Support\Uploads;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use App\Api\ImageResize;
|
use App\Api\ImageResize;
|
||||||
use App\Http\Requests\Dashboard\Product\Store as StoreRequest;
|
use App\Http\Requests\Dashboard\Product\Store as StoreRequest;
|
||||||
@@ -54,10 +55,10 @@ class Child
|
|||||||
$folder = Carbon::now()->format('Y/m/d');
|
$folder = Carbon::now()->format('Y/m/d');
|
||||||
|
|
||||||
// Store original
|
// Store original
|
||||||
$path = $screen['image']->store("uploads/screens/{$folder}");
|
$path = Uploads::store($screen['image'], "uploads/screens/{$folder}");
|
||||||
|
|
||||||
// Store and resize thumb
|
// Store and resize thumb
|
||||||
$tempPath = $screen['image']->store('temp', 'public');
|
$tempPath = Uploads::store($screen['image'], 'temp', 'public');
|
||||||
$thumbPath = $this->image->resize($tempPath, 322, 'screens', true);
|
$thumbPath = $this->image->resize($tempPath, 322, 'screens', true);
|
||||||
|
|
||||||
$this->size = Storage::size($path);
|
$this->size = Storage::size($path);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace App\Jobs\Dashboard\Product;
|
|||||||
|
|
||||||
use App\Models\Product;
|
use App\Models\Product;
|
||||||
use App\Models\Screen;
|
use App\Models\Screen;
|
||||||
|
use App\Support\Uploads;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
|
||||||
use App\Api\ImageResize;
|
use App\Api\ImageResize;
|
||||||
@@ -83,10 +84,10 @@ class ChildUpdate
|
|||||||
$folder = Carbon::now()->format('Y/m/d');
|
$folder = Carbon::now()->format('Y/m/d');
|
||||||
if ($screen['image']) {
|
if ($screen['image']) {
|
||||||
// 1. Store original (S3 if enabled)
|
// 1. Store original (S3 if enabled)
|
||||||
$path = $screen['image']->store("uploads/screens/{$folder}");
|
$path = Uploads::store($screen['image'], "uploads/screens/{$folder}");
|
||||||
|
|
||||||
// 2. Local temp for resizing
|
// 2. Local temp for resizing
|
||||||
$tempPath = $screen['image']->store('temp', 'public');
|
$tempPath = Uploads::store($screen['image'], 'temp', 'public');
|
||||||
$thumbPath = $this->image->resize($tempPath, 322, 'screens', true);
|
$thumbPath = $this->image->resize($tempPath, 322, 'screens', true);
|
||||||
|
|
||||||
Screen::create([
|
Screen::create([
|
||||||
@@ -94,7 +95,7 @@ class ChildUpdate
|
|||||||
'path_thumb' => $thumbPath,
|
'path_thumb' => $thumbPath,
|
||||||
'name' => basename($path),
|
'name' => basename($path),
|
||||||
'product_id' => $child_id,
|
'product_id' => $child_id,
|
||||||
'size' => Storage::disk(env('FILESYSTEM_DISK'))->size($path)
|
'size' => Storage::size($path)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Jobs\Dashboard\Product;
|
namespace App\Jobs\Dashboard\Product;
|
||||||
|
|
||||||
|
use App\Support\Uploads;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
use App\Models\Screen as Screens;
|
use App\Models\Screen as Screens;
|
||||||
@@ -38,17 +39,17 @@ class Screen
|
|||||||
$folder = Carbon::now()->format('Y/m/d');
|
$folder = Carbon::now()->format('Y/m/d');
|
||||||
|
|
||||||
// 1. Store original (S3 if enabled)
|
// 1. Store original (S3 if enabled)
|
||||||
$path = $screen->store("uploads/screens/original/{$folder}");
|
$path = Uploads::store($screen, "uploads/screens/original/{$folder}");
|
||||||
|
|
||||||
// 2. Local temp for resizing
|
// 2. Local temp for resizing
|
||||||
$tempPath = $screen->store('temp', 'public');
|
$tempPath = Uploads::store($screen, 'temp', 'public');
|
||||||
$thumb = $this->img->resize($tempPath, 350, 'screens', true);
|
$thumb = $this->img->resize($tempPath, 350, 'screens', true);
|
||||||
|
|
||||||
$screens = new Screens();
|
$screens = new Screens();
|
||||||
$screens->name = basename($path);
|
$screens->name = basename($path);
|
||||||
$screens->path = $path;
|
$screens->path = $path;
|
||||||
$screens->path_thumb = $thumb;
|
$screens->path_thumb = $thumb;
|
||||||
$screens->size = Storage::disk(env('FILESYSTEM_DISK'))->size($path);
|
$screens->size = Storage::size($path);
|
||||||
$screens->product_id = $this->id;
|
$screens->product_id = $this->id;
|
||||||
$screens->save();
|
$screens->save();
|
||||||
}
|
}
|
||||||
|
|||||||
32
app/Support/Uploads.php
Normal file
32
app/Support/Uploads.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Support;
|
||||||
|
|
||||||
|
use Illuminate\Http\UploadedFile;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use RuntimeException;
|
||||||
|
|
||||||
|
class Uploads
|
||||||
|
{
|
||||||
|
public static function store(UploadedFile $file, string $path, ?string $disk = null): string
|
||||||
|
{
|
||||||
|
$storedPath = $disk ? $file->store($path, $disk) : $file->store($path);
|
||||||
|
|
||||||
|
if (!$storedPath) {
|
||||||
|
throw new RuntimeException("File upload failed: {$path}");
|
||||||
|
}
|
||||||
|
|
||||||
|
return $storedPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function put(string $path, string $contents, ?string $disk = null): void
|
||||||
|
{
|
||||||
|
$stored = $disk
|
||||||
|
? Storage::disk($disk)->put($path, $contents)
|
||||||
|
: Storage::put($path, $contents);
|
||||||
|
|
||||||
|
if (!$stored) {
|
||||||
|
throw new RuntimeException("File upload failed: {$path}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -66,6 +66,7 @@ return [
|
|||||||
'use_path_style_endpoint' => env('MINIO_USE_PATH_STYLE', true),
|
'use_path_style_endpoint' => env('MINIO_USE_PATH_STYLE', true),
|
||||||
'visibility' => 'public',
|
'visibility' => 'public',
|
||||||
'signature_version' => 'v4',
|
'signature_version' => 'v4',
|
||||||
|
'throw' => true,
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
menu = document.querySelector('.main-menu-content');
|
menu = document.querySelector('.main-menu-content');
|
||||||
|
if (!activeEl || !menu) {
|
||||||
|
this.obj.update();
|
||||||
|
return;
|
||||||
|
}
|
||||||
activeEl = activeEl.getBoundingClientRect().top + menu.scrollTop;
|
activeEl = activeEl.getBoundingClientRect().top + menu.scrollTop;
|
||||||
// If active element's top position is less than 2/3 (66%) of menu height than do not scroll
|
// If active element's top position is less than 2/3 (66%) of menu height than do not scroll
|
||||||
if (activeEl > parseInt((menu.clientHeight * 2) / 3)) {
|
if (activeEl > parseInt((menu.clientHeight * 2) / 3)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user