Compare commits
2 Commits
2ba5677c45
...
bb733d14c1
| Author | SHA1 | Date | |
|---|---|---|---|
| bb733d14c1 | |||
| 3aa4601229 |
@@ -10,79 +10,71 @@ class ImageResize
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @return string
|
* @return string relative path used as S3 key, e.g. uploads/posters/thumbs/2024/01/01
|
||||||
*/
|
*/
|
||||||
private function mkdir(string $type)
|
private function thumbFolder(string $type): string
|
||||||
{
|
{
|
||||||
$folder = Carbon::now()->format('Y/m/d');
|
$folder = Carbon::now()->format('Y/m/d');
|
||||||
$path = "uploads/{$type}/thumbs/{$folder}";
|
return "uploads/{$type}/thumbs/{$folder}";
|
||||||
|
|
||||||
if (!file_exists(public_path($path))) {
|
|
||||||
mkdir(public_path($path), 0775, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $path
|
* Resize an image and upload to S3/MinIO (or save locally).
|
||||||
* @param $size
|
*
|
||||||
* @param $type
|
* @param string $path Relative path of the source image (from 'public' disk = storage/app/public/)
|
||||||
* @param bool $deleteOriginal
|
* @param int $size Target width in pixels
|
||||||
* @return string
|
* @param string $type Subfolder name (posters, screens, brands …)
|
||||||
* @throws \Exception
|
* @param bool $deleteOriginal Delete the source file after resizing
|
||||||
|
* @return string Relative path (S3 key) of the generated thumb
|
||||||
*/
|
*/
|
||||||
public function resize($path, $size, $type, $deleteOriginal = false)
|
public function resize(string $path, int $size, string $type, bool $deleteOriginal = false): string
|
||||||
{
|
{
|
||||||
// 1. Resolve source path
|
// 1. Locate the source file (stored via ->store('temp', 'public'))
|
||||||
$srcPath = file_exists(public_path($path))
|
$srcPath = storage_path('app/public/' . $path);
|
||||||
? public_path($path)
|
|
||||||
: storage_path('app/public/' . $path);
|
|
||||||
|
|
||||||
if (!file_exists($srcPath)) {
|
if (!file_exists($srcPath)) {
|
||||||
if (file_exists($path)) {
|
throw new \Exception("Source image not found: {$srcPath}");
|
||||||
$srcPath = $path;
|
|
||||||
} else {
|
|
||||||
// Last ditch effort: try to get from S3 if it's not local
|
|
||||||
if (env('FILESYSTEM_DISK') == 's3' && Storage::disk('s3')->exists($path)) {
|
|
||||||
$fileContent = Storage::disk('s3')->get($path);
|
|
||||||
$tmpLocal = storage_path('app/public/temp_' . basename($path));
|
|
||||||
file_put_contents($tmpLocal, $fileContent);
|
|
||||||
$srcPath = $tmpLocal;
|
|
||||||
$deleteOriginal = true; // Clean up the temp download
|
|
||||||
} else {
|
|
||||||
throw new \Exception("Source image not found: " . $path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Prepare thumb destination
|
// 2. Resize into a temp file in storage/app/public/tmp/
|
||||||
$name = basename($path);
|
$tmpDir = storage_path('app/public/tmp');
|
||||||
$folder = $this->mkdir($type);
|
if (!is_dir($tmpDir)) {
|
||||||
$path_thumb = "{$folder}/{$name}";
|
mkdir($tmpDir, 0775, true);
|
||||||
$absPathThumb = public_path($path_thumb);
|
}
|
||||||
|
|
||||||
|
$thumbFilename = basename($path);
|
||||||
|
$tmpThumb = "{$tmpDir}/{$thumbFilename}";
|
||||||
|
|
||||||
// 3. Resize and Save Thumb
|
|
||||||
$img = Imagee::make($srcPath);
|
$img = Imagee::make($srcPath);
|
||||||
$img->resize($size, null, function ($constraint) {
|
$img->resize($size, null, function ($constraint) {
|
||||||
$constraint->aspectRatio();
|
$constraint->aspectRatio();
|
||||||
});
|
});
|
||||||
$img->save($absPathThumb, 100);
|
$img->save($tmpThumb, 90);
|
||||||
|
|
||||||
// 4. Handle S3 Upload
|
// 3. Upload thumb to S3/MinIO
|
||||||
if (env('FILESYSTEM_DISK') == 's3') {
|
$thumbKey = $this->thumbFolder($type) . '/' . $thumbFilename;
|
||||||
Storage::disk('s3')->put($path_thumb, file_get_contents($absPathThumb));
|
|
||||||
// Remove local thumb after S3 upload
|
if (env('FILESYSTEM_DISK') === 's3') {
|
||||||
if (file_exists($absPathThumb)) {
|
Storage::disk('s3')->put($thumbKey, file_get_contents($tmpThumb));
|
||||||
unlink($absPathThumb);
|
} else {
|
||||||
|
// Local: move to public/uploads/…/thumbs/…
|
||||||
|
$localDir = public_path(dirname($thumbKey));
|
||||||
|
if (!is_dir($localDir)) {
|
||||||
|
mkdir($localDir, 0775, true);
|
||||||
}
|
}
|
||||||
|
rename($tmpThumb, public_path($thumbKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. Cleanup original if requested
|
// 4. Clean up tmp thumb
|
||||||
|
if (file_exists($tmpThumb)) {
|
||||||
|
unlink($tmpThumb);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. Clean up original temp file if requested
|
||||||
if ($deleteOriginal && file_exists($srcPath)) {
|
if ($deleteOriginal && file_exists($srcPath)) {
|
||||||
unlink($srcPath);
|
unlink($srcPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $path_thumb;
|
return $thumbKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,17 +54,8 @@ class Controller extends ExController
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($request->hasFile('image')) {
|
if ($request->hasFile('image')) {
|
||||||
if (env('FILESYSTEM_DISK') == 's3') {
|
Storage::delete($brand->image);
|
||||||
// delete old image from s3
|
$path = $this->storeImageToS3($request->file('image'));
|
||||||
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');
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$path = $brand->image;
|
$path = $brand->image;
|
||||||
}
|
}
|
||||||
@@ -87,12 +78,7 @@ class Controller extends ExController
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($request->hasFile('image')) {
|
if ($request->hasFile('image')) {
|
||||||
$file = $request->file('image');
|
$path = $this->storeImageToS3($request->file('image'));
|
||||||
if (env('FILESYSTEM_DISK') == 's3') {
|
|
||||||
$path = $this->storeImageToS3($file);
|
|
||||||
} else {
|
|
||||||
$path = $file->store('uploads/brands');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->dispatchSync(StoreJob::fromRequest($request, $path));
|
$this->dispatchSync(StoreJob::fromRequest($request, $path));
|
||||||
@@ -109,14 +95,7 @@ class Controller extends ExController
|
|||||||
{
|
{
|
||||||
$this->authorize('delete', 'brands');
|
$this->authorize('delete', 'brands');
|
||||||
|
|
||||||
if (is_file($brand->image)) {
|
Storage::delete($brand->image);
|
||||||
unlink($brand->image);
|
|
||||||
}
|
|
||||||
|
|
||||||
// delete image from s3
|
|
||||||
if (env('FILESYSTEM_DISK') == 's3') {
|
|
||||||
Storage::disk('s3')->delete($brand->image);
|
|
||||||
}
|
|
||||||
|
|
||||||
Product::where('brand_id', $brand->id)->withTrashed()->update([
|
Product::where('brand_id', $brand->id)->withTrashed()->update([
|
||||||
'brand_id' => null
|
'brand_id' => null
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ use App\Jobs\Dashboard\Category\Store as StoreJob;
|
|||||||
use App\Jobs\Dashboard\Category\Update as UpdateJob;
|
use App\Jobs\Dashboard\Category\Update as UpdateJob;
|
||||||
use App\Models\Characteristic;
|
use App\Models\Characteristic;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
class Controller extends ExController
|
class Controller extends ExController
|
||||||
@@ -155,14 +156,7 @@ class Controller extends ExController
|
|||||||
$this->authorize('delete', 'categories');
|
$this->authorize('delete', 'categories');
|
||||||
$category = Category::findOrFail($category);
|
$category = Category::findOrFail($category);
|
||||||
|
|
||||||
if (is_file($category->image)) {
|
Storage::delete($category->image);
|
||||||
unlink($category->image);
|
|
||||||
}
|
|
||||||
|
|
||||||
// delete image from s3
|
|
||||||
if (env('FILESYSTEM_DISK') == 's3') {
|
|
||||||
Storage::disk('s3')->delete($category->image);
|
|
||||||
}
|
|
||||||
|
|
||||||
$category->delete();
|
$category->delete();
|
||||||
$this->info(trans('admin.messages.deleted'));
|
$this->info(trans('admin.messages.deleted'));
|
||||||
@@ -175,29 +169,9 @@ class Controller extends ExController
|
|||||||
*/
|
*/
|
||||||
public function position_save(Request $request)
|
public function position_save(Request $request)
|
||||||
{
|
{
|
||||||
foreach ($request->categories as $category) {
|
DB::transaction(function () use ($request) {
|
||||||
$cat = Category::find($category['id']);
|
$this->saveCategoryPositions($request->input('categories', []), null);
|
||||||
$cat->parent_id = $category['parent_id'] === 'null' ? null : $category['parent_id'];
|
});
|
||||||
$cat->position = $category['position'];
|
|
||||||
$cat->save();
|
|
||||||
if (!empty($category['children'])) {
|
|
||||||
foreach ($category['children'] as $c) {
|
|
||||||
$cc = Category::find($c['id']);
|
|
||||||
$cc->parent_id = $c['parent_id'] === 'null' ? null : $c['parent_id'];
|
|
||||||
$cc->position = $c['position'];
|
|
||||||
$cc->save();
|
|
||||||
|
|
||||||
if (!empty($c['children'])) {
|
|
||||||
foreach ($c['children'] as $ccc) {
|
|
||||||
$cccc = Category::find($ccc['id']);
|
|
||||||
$cccc->parent_id = $ccc['parent_id'] === 'null' ? null : $ccc['parent_id'];
|
|
||||||
$cccc->position = $ccc['position'];
|
|
||||||
$cccc->save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->info(trans('admin.messages.updated'));
|
$this->info(trans('admin.messages.updated'));
|
||||||
|
|
||||||
@@ -206,6 +180,34 @@ class Controller extends ExController
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function saveCategoryPositions(array $categories, $parentId = null): void
|
||||||
|
{
|
||||||
|
foreach (array_values($categories) as $index => $category) {
|
||||||
|
$cat = Category::find($category['id'] ?? null);
|
||||||
|
|
||||||
|
if (!$cat) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$cat->parent_id = $this->normalizeParentId($parentId);
|
||||||
|
$cat->position = $index + 1;
|
||||||
|
$cat->save();
|
||||||
|
|
||||||
|
if (!empty($category['children']) && is_array($category['children'])) {
|
||||||
|
$this->saveCategoryPositions($category['children'], $cat->id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function normalizeParentId($parentId)
|
||||||
|
{
|
||||||
|
if (in_array($parentId, [null, '', 'null', 'NULL', 0, '0'], true)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $parentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
|
|||||||
@@ -45,23 +45,22 @@ class Controller extends ExController
|
|||||||
return view('dashboard.compilations.index', compact('compilations'));
|
return view('dashboard.compilations.index', compact('compilations'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// public function store(StoreRequest $request)
|
public function store(StoreRequest $request)
|
||||||
// {
|
{
|
||||||
// if ($request->isMethod('get')) {
|
if ($request->isMethod('get')) {
|
||||||
// $this->authorize('create', 'compilations');
|
$this->authorize('create', 'compilations');
|
||||||
//
|
|
||||||
//// $this->authorize('content-manager');
|
$categories = $this->categories->whereNull('parent_id')->orderBy('position')->get();
|
||||||
// $categories = $this->categories->where('parent_id', null)->get();
|
return view('dashboard.compilations.store', compact('categories'));
|
||||||
// return view('dashboard.compilations.store', compact('categories'));
|
}
|
||||||
// }
|
|
||||||
//
|
$this->dispatchSync(new StoreJob($request));
|
||||||
// $this->dispatchSync(new StoreJob($request));
|
|
||||||
//
|
$this->success(trans('admin.messages.created'));
|
||||||
// $this->success(trans('admin.messages.created'));
|
return response()->json([
|
||||||
// return response()->json([
|
'status' => true
|
||||||
// 'status' => true
|
]);
|
||||||
// ]);
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Compilation $compilation
|
* @param Compilation $compilation
|
||||||
@@ -74,17 +73,20 @@ class Controller extends ExController
|
|||||||
if ($request->isMethod('get')) {
|
if ($request->isMethod('get')) {
|
||||||
// $this->authorize('content-manager');
|
// $this->authorize('content-manager');
|
||||||
|
|
||||||
$compilation->loadMissing(['products:id,name,poster']);
|
|
||||||
|
|
||||||
$this->authorize('update', 'compilations');
|
$this->authorize('update', 'compilations');
|
||||||
|
|
||||||
foreach ($compilation->products as $product) {
|
$products = $compilation->dashboardProducts()
|
||||||
$product->poster = '/'. $product->poster;
|
->select('products.id', 'products.name', 'products.poster')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
foreach ($products as $product) {
|
||||||
|
$product->poster = $product->getPoster();
|
||||||
$product->name = $product->name['ru'];
|
$product->name = $product->name['ru'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$compilation->setRelation('products', $products);
|
||||||
|
|
||||||
$categories = $this->categories->where('parent_id', false)->get();
|
$categories = $this->categories->whereNull('parent_id')->orderBy('position')->get();
|
||||||
|
|
||||||
|
|
||||||
return view('dashboard.compilations.update', compact('compilation', 'categories'));
|
return view('dashboard.compilations.update', compact('compilation', 'categories'));
|
||||||
@@ -104,12 +106,34 @@ class Controller extends ExController
|
|||||||
*/
|
*/
|
||||||
public function search(Request $request)
|
public function search(Request $request)
|
||||||
{
|
{
|
||||||
$query = $request->name;
|
$query = trim((string) $request->name);
|
||||||
|
$categoryId = (int) $request->get('category_id');
|
||||||
|
|
||||||
$product = $this->products->published()->where('name->ru', 'like', $query . '%')->get()->map(function ($product) {
|
$product = $this->products
|
||||||
|
->newQuery()
|
||||||
|
->whereNull('child_id')
|
||||||
|
->when($categoryId > 0, function ($builder) use ($categoryId) {
|
||||||
|
$categoryIds = $this->categoryIdsWithChildren($categoryId);
|
||||||
|
|
||||||
|
$builder->whereHas('categories', function ($category) use ($categoryIds) {
|
||||||
|
$category->whereIn('categories.id', $categoryIds);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->when($query !== '', function ($builder) use ($query) {
|
||||||
|
$builder->where(function ($search) use ($query) {
|
||||||
|
$search
|
||||||
|
->where('name->ru', 'like', '%' . $query . '%')
|
||||||
|
->orWhere('name->uz', 'like', '%' . $query . '%')
|
||||||
|
->orWhere('article_number', 'like', '%' . $query . '%');
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->orderBy('id', 'desc')
|
||||||
|
->limit(30)
|
||||||
|
->get()
|
||||||
|
->map(function ($product) {
|
||||||
return [
|
return [
|
||||||
'id' => $product->id,
|
'id' => $product->id,
|
||||||
'poster' => '/' . $product->poster,
|
'poster' => $product->getPoster(),
|
||||||
'name' => $product->name['ru']
|
'name' => $product->name['ru']
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
@@ -120,6 +144,27 @@ class Controller extends ExController
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function categoryIdsWithChildren(int $categoryId): array
|
||||||
|
{
|
||||||
|
$category = Category::with('children.children')->find($categoryId);
|
||||||
|
|
||||||
|
if (!$category) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$ids = [$category->id];
|
||||||
|
|
||||||
|
foreach ($category->children as $child) {
|
||||||
|
$ids[] = $child->id;
|
||||||
|
|
||||||
|
foreach ($child->children as $grandChild) {
|
||||||
|
$ids[] = $grandChild->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Compilation $compilation
|
* @param Compilation $compilation
|
||||||
|
|||||||
@@ -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\Store as StoreJob;
|
||||||
use App\Jobs\Dashboard\Partner\Update as UpdateJob;
|
use App\Jobs\Dashboard\Partner\Update as UpdateJob;
|
||||||
use Illuminate\Support\Facades\File;
|
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
class Controller extends ExController
|
class Controller extends ExController
|
||||||
@@ -48,19 +47,8 @@ class Controller extends ExController
|
|||||||
public function update(UpdateRequest $request, Partner $partner)
|
public function update(UpdateRequest $request, Partner $partner)
|
||||||
{
|
{
|
||||||
if ($request->hasFile('image')) {
|
if ($request->hasFile('image')) {
|
||||||
if (env('FILESYSTEM_DISK') == 's3') {
|
Storage::delete($partner->image);
|
||||||
// delete old image from s3
|
$path = $request->file('image')->store('uploads/partners');
|
||||||
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');
|
|
||||||
} else {
|
} else {
|
||||||
$path = $partner->image;
|
$path = $partner->image;
|
||||||
}
|
}
|
||||||
@@ -75,17 +63,7 @@ class Controller extends ExController
|
|||||||
{
|
{
|
||||||
$this->authorize('delete', 'partners');
|
$this->authorize('delete', 'partners');
|
||||||
|
|
||||||
if (env('FILESYSTEM_DISK') == 's3') {
|
Storage::delete($partner->image);
|
||||||
// delete old image from s3
|
|
||||||
Storage::disk('s3')->delete($partner->image);
|
|
||||||
} else {
|
|
||||||
$imagePath = public_path($partner->image);
|
|
||||||
|
|
||||||
if (File::exists($imagePath)) {
|
|
||||||
File::delete($imagePath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$partner->delete();
|
$partner->delete();
|
||||||
|
|
||||||
$this->info(trans('admin.messages.deleted'));
|
$this->info(trans('admin.messages.deleted'));
|
||||||
|
|||||||
@@ -57,14 +57,8 @@ class Controller extends ExController
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($request->hasFile('image')) {
|
if ($request->hasFile('image')) {
|
||||||
if (env('FILESYSTEM_DISK') == 's3') {
|
Storage::delete($post->image);
|
||||||
Storage::disk('s3')->delete($post->image);
|
$path = $request->file('image')->store('uploads/posts');
|
||||||
} else {
|
|
||||||
if (is_file($post->image)) {
|
|
||||||
unlink($post->image);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$path = $request->file('image')->store('uploads/posts');
|
|
||||||
} else {
|
} else {
|
||||||
$path = $post->image;
|
$path = $post->image;
|
||||||
}
|
}
|
||||||
@@ -122,14 +116,7 @@ class Controller extends ExController
|
|||||||
public function delete(Post $post)
|
public function delete(Post $post)
|
||||||
{
|
{
|
||||||
$this->authorize('delete', 'posts');
|
$this->authorize('delete', 'posts');
|
||||||
if (env('FILESYSTEM_DISK') == 's3') {
|
Storage::delete($post->image);
|
||||||
Storage::disk('s3')->delete($post->image);
|
|
||||||
} else {
|
|
||||||
if (is_file($post->image)) {
|
|
||||||
unlink($post->image);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$post->delete();
|
$post->delete();
|
||||||
$this->info(trans('admin.messages.deleted'));
|
$this->info(trans('admin.messages.deleted'));
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
|
|||||||
@@ -283,11 +283,7 @@ class Controller extends ExController
|
|||||||
foreach ($product->childrens as $children) {
|
foreach ($product->childrens as $children) {
|
||||||
foreach ($children->screens as $screen) {
|
foreach ($children->screens as $screen) {
|
||||||
$screen->sizeText = $screen->size / 1024 . 'Kb';
|
$screen->sizeText = $screen->size / 1024 . 'Kb';
|
||||||
if (env('FILESYSTEM_DISK') == 's3') {
|
$screen->url = Storage::url($screen->path);
|
||||||
$screen->url = Storage::url($screen->path);
|
|
||||||
} else {
|
|
||||||
$screen->url = '/' . $screen->path;
|
|
||||||
}
|
|
||||||
$screen->type = "image/jpeg";
|
$screen->type = "image/jpeg";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -318,15 +314,15 @@ class Controller extends ExController
|
|||||||
try {
|
try {
|
||||||
$this->dispatchSync(new UpdateJob($product, $request));
|
$this->dispatchSync(new UpdateJob($product, $request));
|
||||||
$this->dispatchSync(new ChildUpdateJob($request, $product));
|
$this->dispatchSync(new ChildUpdateJob($request, $product));
|
||||||
|
$this->charSync($product, $request->characteristics);
|
||||||
|
$this->dispatchSync(new DeletesJob($request));
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
return Response::json([
|
return Response::json([
|
||||||
"messages" => $e->getMessage()
|
'status' => false,
|
||||||
]);
|
'messages' => $e->getMessage()
|
||||||
|
], 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->charSync($product, $request->characteristics);
|
|
||||||
|
|
||||||
$this->dispatchSync(new DeletesJob($request));
|
|
||||||
$this->info(trans('admin.messages.updated'));
|
$this->info(trans('admin.messages.updated'));
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
@@ -394,8 +390,12 @@ class Controller extends ExController
|
|||||||
$article_number = empty($request->get('article_number')) ? null : $request->get('article_number');
|
$article_number = empty($request->get('article_number')) ? null : $request->get('article_number');
|
||||||
|
|
||||||
if ($category) {
|
if ($category) {
|
||||||
$categoryFind = Category::find($category);
|
$categoryFind = Category::withTrashed()->find($category);
|
||||||
list($categoryFind, $category_id) = $this->categoryQuery->getCategoriesAndCategoryMainId($categoryFind);
|
if ($categoryFind) {
|
||||||
|
list($categoryFind, $category_id) = $this->categoryQuery->getCategoriesAndCategoryMainId($categoryFind);
|
||||||
|
} else {
|
||||||
|
$category_id = [];
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$category_id = [];
|
$category_id = [];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ use App\Jobs\Dashboard\Service\Store as StoreJob;
|
|||||||
use App\Jobs\Dashboard\Service\Update as UpdateJob;
|
use App\Jobs\Dashboard\Service\Update as UpdateJob;
|
||||||
use App\Models\Problem;
|
use App\Models\Problem;
|
||||||
use App\Models\ServiceProblem;
|
use App\Models\ServiceProblem;
|
||||||
use Illuminate\Support\Facades\File;
|
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
class Controller extends ExController
|
class Controller extends ExController
|
||||||
@@ -62,18 +61,8 @@ class Controller extends ExController
|
|||||||
public function update(UpdateRequest $request, Service $service)
|
public function update(UpdateRequest $request, Service $service)
|
||||||
{
|
{
|
||||||
if ($request->hasFile('image')) {
|
if ($request->hasFile('image')) {
|
||||||
if (env('FILESYSTEM_DISK') == 's3') {
|
Storage::delete($service->image);
|
||||||
$imagePath = $service->image;
|
$path = $request->file('image')->store('uploads/services');
|
||||||
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');
|
|
||||||
} else {
|
} else {
|
||||||
$path = $service->image;
|
$path = $service->image;
|
||||||
}
|
}
|
||||||
@@ -106,17 +95,7 @@ class Controller extends ExController
|
|||||||
{
|
{
|
||||||
$this->authorize('delete', 'services');
|
$this->authorize('delete', 'services');
|
||||||
|
|
||||||
if (env('FILESYSTEM_DISK') == 's3') {
|
Storage::delete($service->image);
|
||||||
$imagePath = $service->image;
|
|
||||||
Storage::disk('s3')->delete($imagePath);
|
|
||||||
} else {
|
|
||||||
$imagePath = public_path($service->image);
|
|
||||||
|
|
||||||
if (File::exists($imagePath)) {
|
|
||||||
File::delete($imagePath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ServiceProblem::where('service_id', $service->id)->delete();
|
ServiceProblem::where('service_id', $service->id)->delete();
|
||||||
|
|
||||||
$service->delete();
|
$service->delete();
|
||||||
|
|||||||
@@ -49,18 +49,8 @@ class Controller extends ExController
|
|||||||
public function update(UpdateRequest $request, UsefulInfo $usefulinfo)
|
public function update(UpdateRequest $request, UsefulInfo $usefulinfo)
|
||||||
{
|
{
|
||||||
if ($request->hasFile('image')) {
|
if ($request->hasFile('image')) {
|
||||||
if (env('FILESYSTEM_DISK') == 's3') {
|
Storage::delete($usefulinfo->image);
|
||||||
$imagePath = $usefulinfo->image;
|
$path = $request->file('image')->store('uploads/usefulinfos');
|
||||||
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');
|
|
||||||
} else {
|
} else {
|
||||||
$path = $usefulinfo->image;
|
$path = $usefulinfo->image;
|
||||||
}
|
}
|
||||||
@@ -84,17 +74,7 @@ class Controller extends ExController
|
|||||||
$item->delete();
|
$item->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (env('FILESYSTEM_DISK') == 's3') {
|
Storage::delete($usefulinfo->image);
|
||||||
$imagePath = $usefulinfo->image;
|
|
||||||
Storage::disk('s3')->delete($imagePath);
|
|
||||||
} else {
|
|
||||||
$imagePath = public_path($usefulinfo->image);
|
|
||||||
|
|
||||||
if (File::exists($imagePath)) {
|
|
||||||
File::delete($imagePath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$usefulinfo->delete();
|
$usefulinfo->delete();
|
||||||
|
|
||||||
$this->info(trans('admin.messages.deleted'));
|
$this->info(trans('admin.messages.deleted'));
|
||||||
|
|||||||
@@ -40,26 +40,14 @@ class Update extends FormRequest
|
|||||||
return Str::slug($this->get('name')['uz']);
|
return Str::slug($this->get('name')['uz']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getImage(Category $category): string
|
public function getImage(Category $category): ?string
|
||||||
{
|
{
|
||||||
if ($this->hasFile('image')) {
|
if ($this->hasFile('image')) {
|
||||||
if (env('FILESYSTEM_DISK') == 's3') {
|
Storage::delete($category->image);
|
||||||
// delete old image from s3
|
return (string) $this->file('image')->store('uploads/categories');
|
||||||
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');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return 'null';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $category->image;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFilterPower()
|
public function getFilterPower()
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ class Store extends FormRequest
|
|||||||
return [
|
return [
|
||||||
'title' => 'array',
|
'title' => 'array',
|
||||||
'title.*' => 'required',
|
'title.*' => 'required',
|
||||||
'published' => 'required',
|
'published' => 'nullable',
|
||||||
|
'products' => 'nullable|array',
|
||||||
//'category_id' => 'required'
|
//'category_id' => 'required'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -40,7 +41,7 @@ class Store extends FormRequest
|
|||||||
*/
|
*/
|
||||||
public function getPublished(): bool
|
public function getPublished(): bool
|
||||||
{
|
{
|
||||||
return $this->get('published');
|
return filter_var($this->get('published', false), FILTER_VALIDATE_BOOLEAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -49,8 +50,8 @@ class Store extends FormRequest
|
|||||||
*/
|
*/
|
||||||
public function getCategory()
|
public function getCategory()
|
||||||
{
|
{
|
||||||
if ($this->get('category_id')) {
|
if ($this->get('category_id') && $this->get('category_id') != 0) {
|
||||||
$this->get('category_id');
|
return $this->get('category_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ class Update extends FormRequest
|
|||||||
return [
|
return [
|
||||||
'title' => 'array',
|
'title' => 'array',
|
||||||
'title.*' => 'required',
|
'title.*' => 'required',
|
||||||
'published' => 'required',
|
'published' => 'nullable',
|
||||||
|
'products' => 'nullable|array',
|
||||||
//'category_id' => 'required',
|
//'category_id' => 'required',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -40,14 +41,14 @@ class Update extends FormRequest
|
|||||||
*/
|
*/
|
||||||
public function getPublished(): bool
|
public function getPublished(): bool
|
||||||
{
|
{
|
||||||
return $this->get('published');
|
return filter_var($this->get('published', false), FILTER_VALIDATE_BOOLEAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getCategory()
|
public function getCategory()
|
||||||
{
|
{
|
||||||
if ($this->get('category_id')) {
|
if ($this->get('category_id') && $this->get('category_id') != 0) {
|
||||||
$this->get('category_id');
|
return $this->get('category_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -63,15 +63,7 @@ class Update extends FormRequest
|
|||||||
public function getPoster(Product $product): string
|
public function getPoster(Product $product): string
|
||||||
{
|
{
|
||||||
if ($this->hasFile('poster')) {
|
if ($this->hasFile('poster')) {
|
||||||
if (env('FILESYSTEM_DISK') == 's3') {
|
Storage::delete($product->poster);
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
$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 (string) $this->file('poster')->store($folder);
|
||||||
}
|
}
|
||||||
@@ -85,13 +77,9 @@ class Update extends FormRequest
|
|||||||
public function getCalc(Product $product): string|null
|
public function getCalc(Product $product): string|null
|
||||||
{
|
{
|
||||||
if ($this->hasFile('calc')) {
|
if ($this->hasFile('calc')) {
|
||||||
if (env('FILESYSTEM_DISK') == 's3' and $product->calc) {
|
if ($product->calc) {
|
||||||
// delete old file from s3
|
Storage::delete($product->calc);
|
||||||
Storage::disk('s3')->delete($product->calc);
|
|
||||||
} elseif($product->calc) {
|
|
||||||
unlink($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 (string) $this->file('calc')->store($folder);
|
||||||
}
|
}
|
||||||
@@ -101,11 +89,9 @@ class Update extends FormRequest
|
|||||||
public function getDataSheet(Product $product)
|
public function getDataSheet(Product $product)
|
||||||
{
|
{
|
||||||
if ($this->hasFile('data_sheet')) {
|
if ($this->hasFile('data_sheet')) {
|
||||||
|
if ($product->data_sheet) {
|
||||||
if (is_file($this->get('data_sheet'))) {
|
Storage::delete($product->data_sheet);
|
||||||
unlink($this->get("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 (string) $this->file('data_sheet')->store($folder);
|
||||||
}
|
}
|
||||||
@@ -119,18 +105,8 @@ class Update extends FormRequest
|
|||||||
public function getPosterThumb(Product $product): string
|
public function getPosterThumb(Product $product): string
|
||||||
{
|
{
|
||||||
if ($this->hasFile('poster')) {
|
if ($this->hasFile('poster')) {
|
||||||
if (env('FILESYSTEM_DISK') == 's3') {
|
Storage::delete($product->poster_thumb);
|
||||||
// delete old file from s3
|
$tempPath = $this->file('poster')->store('temp', 'public');
|
||||||
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');
|
|
||||||
|
|
||||||
$resizer = new ImageResize();
|
$resizer = new ImageResize();
|
||||||
return $resizer->resize($tempPath, 322, 'posters', true);
|
return $resizer->resize($tempPath, 322, 'posters', true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ class Update
|
|||||||
$category->name = $request->getName();
|
$category->name = $request->getName();
|
||||||
$category->slug = $request->getSlug();
|
$category->slug = $request->getSlug();
|
||||||
$category->position = $request->getPosition();
|
$category->position = $request->getPosition();
|
||||||
$category->image = $request->getImage($category);
|
$category->image = $this->image;
|
||||||
// $category->parent_id = $request->getParentId();
|
$category->parent_id = $request->getParentId();
|
||||||
// $category->popular = $request->getPopular();
|
// $category->popular = $request->getPopular();
|
||||||
$category->published = $request->getPublished();
|
$category->published = $request->getPublished();
|
||||||
$category->is_filter_power = $request->getFilterPower();
|
$category->is_filter_power = $request->getFilterPower();
|
||||||
@@ -45,8 +45,6 @@ class Update
|
|||||||
$category->keywords = $request->keywords;
|
$category->keywords = $request->keywords;
|
||||||
$category->title_seo = $request->title_seo;
|
$category->title_seo = $request->title_seo;
|
||||||
|
|
||||||
$category->image = $this->image;
|
|
||||||
|
|
||||||
$category->save();
|
$category->save();
|
||||||
|
|
||||||
if (isset($request->brands)) {
|
if (isset($request->brands)) {
|
||||||
|
|||||||
@@ -36,8 +36,10 @@ class Store
|
|||||||
|
|
||||||
$map = array_map(function ($product) {
|
$map = array_map(function ($product) {
|
||||||
return $product['id'];
|
return $product['id'];
|
||||||
}, $this->request->products);
|
}, $this->request->products ?? []);
|
||||||
|
|
||||||
$compilation->products()->attach($map);
|
if (!empty($map)) {
|
||||||
|
$compilation->products()->attach($map);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,20 +35,12 @@ class Update
|
|||||||
'category_id' => $this->request->getCategory()
|
'category_id' => $this->request->getCategory()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$detach = Compilation::find($this->compilation->id);
|
|
||||||
$detach->loadMissing(['products:id']);
|
|
||||||
|
|
||||||
$compilation = Compilation::find($this->compilation->id);
|
$compilation = Compilation::find($this->compilation->id);
|
||||||
|
|
||||||
$map = array_map(function ($product) {
|
$map = array_map(function ($product) {
|
||||||
return $product['id'];
|
return $product['id'];
|
||||||
}, $this->request->products);
|
}, $this->request->products ?? []);
|
||||||
|
|
||||||
$detach = array_map(function ($product) {
|
$compilation->products()->sync($map);
|
||||||
return $product['id'];
|
|
||||||
}, $detach->products->toArray());
|
|
||||||
|
|
||||||
$compilation->products()->detach($detach);
|
|
||||||
$compilation->products()->attach($map);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,12 +60,7 @@ class Child
|
|||||||
$tempPath = $screen['image']->store('temp', 'public');
|
$tempPath = $screen['image']->store('temp', 'public');
|
||||||
$thumbPath = $this->image->resize($tempPath, 322, 'screens', true);
|
$thumbPath = $this->image->resize($tempPath, 322, 'screens', true);
|
||||||
|
|
||||||
// Get screen size (local or s3)
|
$this->size = Storage::size($path);
|
||||||
if (env('FILESYSTEM_DISK') == 's3') {
|
|
||||||
$this->size = Storage::disk('s3')->size($path);
|
|
||||||
} else {
|
|
||||||
$this->size = filesize(public_path($path));
|
|
||||||
}
|
|
||||||
|
|
||||||
Screen::create([
|
Screen::create([
|
||||||
'path' => $path,
|
'path' => $path,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace App\Jobs\Dashboard\Product;
|
|||||||
use App\Http\Requests\Dashboard\Product\Update as Request;
|
use App\Http\Requests\Dashboard\Product\Update as Request;
|
||||||
use App\Models\Screen;
|
use App\Models\Screen;
|
||||||
use App\Models\Product;
|
use App\Models\Product;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
class Deletes
|
class Deletes
|
||||||
{
|
{
|
||||||
@@ -29,14 +30,7 @@ class Deletes
|
|||||||
foreach ($this->request->deletes['screens'] as $screen) {
|
foreach ($this->request->deletes['screens'] as $screen) {
|
||||||
$sc = Screen::where('id', $screen)->first();
|
$sc = Screen::where('id', $screen)->first();
|
||||||
if (!empty($sc)) {
|
if (!empty($sc)) {
|
||||||
if (is_file($sc->path)) {
|
Storage::delete([$sc->path, $sc->path_thumb]);
|
||||||
unlink($sc->path);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_file($sc->path_thumb)) {
|
|
||||||
unlink($sc->path_thumb);
|
|
||||||
}
|
|
||||||
|
|
||||||
$sc->delete();
|
$sc->delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,12 +62,7 @@ class Brand extends Model
|
|||||||
public function getImage(): string
|
public function getImage(): string
|
||||||
{
|
{
|
||||||
if (!empty($this->image)) {
|
if (!empty($this->image)) {
|
||||||
if (in_array(config('filesystems.default'), ['s3', 'minio'])) {
|
return Storage::url($this->image);
|
||||||
return Storage::url($this->image);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
return (string) '/' . $this->image;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (string) 'images/no_brend.png';
|
return (string) 'images/no_brend.png';
|
||||||
|
|||||||
@@ -147,11 +147,7 @@ class Category extends Model
|
|||||||
public function getImage(): string
|
public function getImage(): string
|
||||||
{
|
{
|
||||||
if (!in_array($this->image, ['null', null])) {
|
if (!in_array($this->image, ['null', null])) {
|
||||||
if (in_array(config('filesystems.default'), ['s3', 'minio'])) {
|
return Storage::url($this->image);
|
||||||
return Storage::url($this->image);
|
|
||||||
}
|
|
||||||
|
|
||||||
return config('app.url') . '/' . $this->image;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return config('app.url') . '/images/nophoto.jpg';
|
return config('app.url') . '/images/nophoto.jpg';
|
||||||
|
|||||||
@@ -58,6 +58,11 @@ class Compilation extends Model
|
|||||||
return $this->belongsToMany(Product::class, 'compilation_products')->where('published', true)->limit(10);
|
return $this->belongsToMany(Product::class, 'compilation_products')->where('published', true)->limit(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function dashboardProducts()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(Product::class, 'compilation_products');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -30,12 +30,9 @@ class ContractTemplate extends Model
|
|||||||
public function full_path(): string
|
public function full_path(): string
|
||||||
{
|
{
|
||||||
if (!empty($this->path)) {
|
if (!empty($this->path)) {
|
||||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
|
return Storage::url($this->path);
|
||||||
return Storage::url($this->path);
|
|
||||||
}
|
|
||||||
return '/' . $this->path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return asset('storage/' . $this->path);
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,10 +47,7 @@ class File extends Model
|
|||||||
public function getPath()
|
public function getPath()
|
||||||
{
|
{
|
||||||
if (!empty($this->path)) {
|
if (!empty($this->path)) {
|
||||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
|
return Storage::url($this->path);
|
||||||
return Storage::url($this->path);
|
|
||||||
}
|
|
||||||
return (string) $this->path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@@ -62,10 +59,7 @@ class File extends Model
|
|||||||
public function getPathThumb()
|
public function getPathThumb()
|
||||||
{
|
{
|
||||||
if (!empty($this->path_thumb)) {
|
if (!empty($this->path_thumb)) {
|
||||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
|
return Storage::url($this->path_thumb);
|
||||||
return Storage::url($this->path_thumb);
|
|
||||||
}
|
|
||||||
return (string) $this->path_thumb;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -36,11 +36,7 @@ class OrderContract extends Model
|
|||||||
public function getPath()
|
public function getPath()
|
||||||
{
|
{
|
||||||
if (!empty($this->path)) {
|
if (!empty($this->path)) {
|
||||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
|
return Storage::url($this->path);
|
||||||
return Storage::url($this->path);
|
|
||||||
}
|
|
||||||
|
|
||||||
return env('APP_URL') . '/storage/' . $this->path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -52,11 +52,7 @@ class Partner extends Model
|
|||||||
public function getImage(): string
|
public function getImage(): string
|
||||||
{
|
{
|
||||||
if (!empty($this->image)) {
|
if (!empty($this->image)) {
|
||||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
|
return Storage::url($this->image);
|
||||||
return Storage::url($this->image);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (string) $this->image;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (string) 'images/no_brend.png';
|
return (string) 'images/no_brend.png';
|
||||||
|
|||||||
@@ -70,11 +70,7 @@ class PaymentSystemItem extends Model
|
|||||||
public function getLogo(): string
|
public function getLogo(): string
|
||||||
{
|
{
|
||||||
if (!empty($this->logo)) {
|
if (!empty($this->logo)) {
|
||||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
|
return Storage::url($this->logo);
|
||||||
return Storage::url($this->logo);
|
|
||||||
}
|
|
||||||
|
|
||||||
return env('APP_URL').'/'.$this->logo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return '/images/nophoto.jpg';
|
return '/images/nophoto.jpg';
|
||||||
|
|||||||
@@ -56,11 +56,7 @@ class Post extends Model
|
|||||||
public function getImage(): string
|
public function getImage(): string
|
||||||
{
|
{
|
||||||
if (!empty($this->image)) {
|
if (!empty($this->image)) {
|
||||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
|
return Storage::url($this->image);
|
||||||
return Storage::url($this->image);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->image;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return '/images/nophoto.jpg';
|
return '/images/nophoto.jpg';
|
||||||
|
|||||||
@@ -236,10 +236,7 @@ class Product extends Model
|
|||||||
public function getPoster(): string
|
public function getPoster(): string
|
||||||
{
|
{
|
||||||
if (!empty($this->poster)) {
|
if (!empty($this->poster)) {
|
||||||
if (in_array(config('filesystems.default'), ['s3', 'minio'])) {
|
return Storage::url($this->poster);
|
||||||
return Storage::url($this->poster);
|
|
||||||
}
|
|
||||||
return config('app.url') . '/' . $this->poster;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return config('app.url') . '/images/no_product.jpg';
|
return config('app.url') . '/images/no_product.jpg';
|
||||||
@@ -248,10 +245,7 @@ class Product extends Model
|
|||||||
public function getDataSheet()
|
public function getDataSheet()
|
||||||
{
|
{
|
||||||
if (!empty($this->data_sheet) and ($this->data_sheet != null and $this->data_sheet != "null")) {
|
if (!empty($this->data_sheet) and ($this->data_sheet != null and $this->data_sheet != "null")) {
|
||||||
if (in_array(config('filesystems.default'), ['s3', 'minio'])) {
|
return Storage::url($this->data_sheet);
|
||||||
return Storage::url($this->data_sheet);
|
|
||||||
}
|
|
||||||
return config('app.url') . '/' . $this->data_sheet;
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -259,10 +253,7 @@ class Product extends Model
|
|||||||
public function getPosterThumb(): string
|
public function getPosterThumb(): string
|
||||||
{
|
{
|
||||||
if (!empty($this->poster_thumb)) {
|
if (!empty($this->poster_thumb)) {
|
||||||
if (in_array(config('filesystems.default'), ['s3', 'minio'])) {
|
return Storage::url($this->poster_thumb);
|
||||||
return Storage::url($this->poster_thumb);
|
|
||||||
}
|
|
||||||
return config('app.url') . '/' . $this->poster_thumb;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return config('app.url') . '/images/no_product.jpg';
|
return config('app.url') . '/images/no_product.jpg';
|
||||||
|
|||||||
@@ -58,10 +58,7 @@ class Screen extends Model
|
|||||||
public function getPath(): string
|
public function getPath(): string
|
||||||
{
|
{
|
||||||
if (!empty($this->path)) {
|
if (!empty($this->path)) {
|
||||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
|
return Storage::url($this->path);
|
||||||
return Storage::url($this->path);
|
|
||||||
}
|
|
||||||
return (string) $this->path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (string) 'image/no_screen.png';
|
return (string) 'image/no_screen.png';
|
||||||
@@ -73,10 +70,7 @@ class Screen extends Model
|
|||||||
public function getPathThumb(): string
|
public function getPathThumb(): string
|
||||||
{
|
{
|
||||||
if (!empty($this->path_thumb)) {
|
if (!empty($this->path_thumb)) {
|
||||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
|
return Storage::url($this->path_thumb);
|
||||||
return Storage::url($this->path_thumb);
|
|
||||||
}
|
|
||||||
return (string) $this->path_thumb;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (string) 'image/no_screen_thumb.png';
|
return (string) 'image/no_screen_thumb.png';
|
||||||
|
|||||||
@@ -61,10 +61,7 @@ class Service extends Model
|
|||||||
public function getImage(): string
|
public function getImage(): string
|
||||||
{
|
{
|
||||||
if (!empty($this->image)) {
|
if (!empty($this->image)) {
|
||||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
|
return Storage::url($this->image);
|
||||||
return Storage::url($this->image);
|
|
||||||
}
|
|
||||||
return (string) $this->image;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (string) 'images/no_brend.png';
|
return (string) 'images/no_brend.png';
|
||||||
|
|||||||
@@ -45,10 +45,7 @@ class Slider extends Model
|
|||||||
public function getImage(): string
|
public function getImage(): string
|
||||||
{
|
{
|
||||||
if (!empty($this->image)) {
|
if (!empty($this->image)) {
|
||||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
|
return Storage::url($this->image);
|
||||||
return Storage::url($this->image);
|
|
||||||
}
|
|
||||||
return $this->image;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return '/images/nophoto.jpg';
|
return '/images/nophoto.jpg';
|
||||||
|
|||||||
@@ -47,10 +47,7 @@ class SpecialOffer extends Model
|
|||||||
public function getImage(): string
|
public function getImage(): string
|
||||||
{
|
{
|
||||||
if (!empty($this->image)) {
|
if (!empty($this->image)) {
|
||||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
|
return Storage::url($this->image);
|
||||||
return Storage::url($this->image);
|
|
||||||
}
|
|
||||||
return (string) $this->image;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (string) 'images/nophoto.png';
|
return (string) 'images/nophoto.png';
|
||||||
|
|||||||
@@ -44,10 +44,7 @@ class UsefulInfo extends Model
|
|||||||
public function getImage(): string
|
public function getImage(): string
|
||||||
{
|
{
|
||||||
if (!empty($this->image)) {
|
if (!empty($this->image)) {
|
||||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
|
return Storage::url($this->image);
|
||||||
return Storage::url($this->image);
|
|
||||||
}
|
|
||||||
return (string) $this->image;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (string) 'images/no_brend.png';
|
return (string) 'images/no_brend.png';
|
||||||
|
|||||||
@@ -63,10 +63,7 @@ class UsefulInfoItem extends Model
|
|||||||
public function getFile(): string
|
public function getFile(): string
|
||||||
{
|
{
|
||||||
if (!empty($this->file_url)) {
|
if (!empty($this->file_url)) {
|
||||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
|
return Storage::url($this->file_url);
|
||||||
return Storage::url($this->file_url);
|
|
||||||
}
|
|
||||||
return '/' . $this->file_url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return '/images/no_product.jpg';
|
return '/images/no_product.jpg';
|
||||||
|
|||||||
@@ -96,13 +96,10 @@ class ContractService
|
|||||||
// 1 - store temp file
|
// 1 - store temp file
|
||||||
$path = storage_path('app/public/' . $oldPath);
|
$path = storage_path('app/public/' . $oldPath);
|
||||||
|
|
||||||
// Store the image on S3 or keep local
|
Storage::put($oldPath, file_get_contents($path));
|
||||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
|
|
||||||
Storage::disk('s3')->put($oldPath, file_get_contents($path));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3 - delete resized file
|
// 3 - delete resized file
|
||||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio']) && is_file($path)) {
|
if (is_file($path)) {
|
||||||
unlink($path);
|
unlink($path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,15 +9,21 @@ server {
|
|||||||
root /quyoshli/public;
|
root /quyoshli/public;
|
||||||
index index.php;
|
index index.php;
|
||||||
|
|
||||||
|
# Final MinIO proxy fix - ^~ is mandatory to override regex blocks
|
||||||
|
location ^~ /quyoshli/ {
|
||||||
|
proxy_set_header Host $proxy_host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_pass http://quyoshli-minio:9100;
|
||||||
|
proxy_buffering off;
|
||||||
|
}
|
||||||
|
|
||||||
# try to serve file directly, fallback to start.php
|
# try to serve file directly, fallback to start.php
|
||||||
location / {
|
location / {
|
||||||
try_files $uri /$uri /index.php$is_args$args;
|
try_files $uri /$uri /index.php$is_args$args;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!-e $request_filename) {
|
|
||||||
rewrite ^.*$ /index.php last;
|
|
||||||
}
|
|
||||||
|
|
||||||
location ~ \.php$ {
|
location ~ \.php$ {
|
||||||
fastcgi_pass quyoshli:9000;
|
fastcgi_pass quyoshli:9000;
|
||||||
fastcgi_index index.php;
|
fastcgi_index index.php;
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 61 KiB |
@@ -34,7 +34,7 @@
|
|||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="category">Категория</label>
|
<label for="category">Категория</label>
|
||||||
<select id="category" class="form-control" v-model="category_id">
|
<select id="category" class="form-control" v-model="category_id" @change="SearchProduct('')">
|
||||||
<option value="0">Все</option>
|
<option value="0">Все</option>
|
||||||
<option v-for="category in categories" :value="category.id">
|
<option v-for="category in categories" :value="category.id">
|
||||||
{{ category.name.ru }}
|
{{ category.name.ru }}
|
||||||
@@ -194,19 +194,17 @@
|
|||||||
async SearchProduct(query) {
|
async SearchProduct(query) {
|
||||||
let name = query;
|
let name = query;
|
||||||
|
|
||||||
if (name.length > 0) {
|
axios.post('/dashboard/compilations/product/search', { name: name, category_id: this.category_id})
|
||||||
axios.post('/dashboard/compilations/product/search', { name: name})
|
.then((response) => {
|
||||||
.then((response) => {
|
if (response.data.status) {
|
||||||
if (response.data.status) {
|
this.products = response.data.products;
|
||||||
this.products = response.data.products;
|
|
||||||
}
|
|
||||||
}).catch((error) => {
|
|
||||||
if (error.response) {
|
|
||||||
this.error = true;
|
|
||||||
this.errors = error.response.data.errors;
|
|
||||||
}
|
}
|
||||||
});
|
}).catch((error) => {
|
||||||
}
|
if (error.response) {
|
||||||
|
this.error = true;
|
||||||
|
this.errors = error.response.data.errors;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
console.log(query);
|
console.log(query);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="category">Категория</label>
|
<label for="category">Категория</label>
|
||||||
<select id="category" class="form-control" v-model="category_id">
|
<select id="category" class="form-control" v-model="category_id" @change="SearchProduct('')">
|
||||||
<option value="0">Все</option>
|
<option value="0">Все</option>
|
||||||
<option v-for="category in categories" :value="category.id">
|
<option v-for="category in categories" :value="category.id">
|
||||||
{{ category.name.ru }}
|
{{ category.name.ru }}
|
||||||
@@ -196,19 +196,17 @@
|
|||||||
async SearchProduct(query) {
|
async SearchProduct(query) {
|
||||||
let name = query;
|
let name = query;
|
||||||
|
|
||||||
if (name.length > 0) {
|
axios.post('/dashboard/compilations/product/search', { name: name, category_id: this.category_id})
|
||||||
axios.post('/dashboard/compilations/product/search', { name: name})
|
.then((response) => {
|
||||||
.then((response) => {
|
if (response.data.status) {
|
||||||
if (response.data.status) {
|
this.products = response.data.products;
|
||||||
this.products = response.data.products;
|
|
||||||
}
|
|
||||||
}).catch((error) => {
|
|
||||||
if (error.response) {
|
|
||||||
this.error = true;
|
|
||||||
this.errors = error.response.data.errors;
|
|
||||||
}
|
}
|
||||||
});
|
}).catch((error) => {
|
||||||
}
|
if (error.response) {
|
||||||
|
this.error = true;
|
||||||
|
this.errors = error.response.data.errors;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
console.log(query);
|
console.log(query);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -137,168 +137,67 @@ export default {
|
|||||||
subCategories: [],
|
subCategories: [],
|
||||||
category: null,
|
category: null,
|
||||||
subCategory: null,
|
subCategory: null,
|
||||||
|
currentParentId: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
async SendForm() {
|
async SendForm() {
|
||||||
const formData = new FormData();
|
|
||||||
for (var i = 0; i < this.categories.length; i++) {
|
|
||||||
formData.append(
|
|
||||||
"categories[" + i + "][id]",
|
|
||||||
this.categories[i].id
|
|
||||||
);
|
|
||||||
formData.append(
|
|
||||||
"categories[" + i + "][position]",
|
|
||||||
this.categories[i].position
|
|
||||||
);
|
|
||||||
formData.append(
|
|
||||||
"categories[" + i + "][parent_id]",
|
|
||||||
this.categories[i].parent_id
|
|
||||||
);
|
|
||||||
if (this.categories[i].children.length > 0) {
|
|
||||||
for (
|
|
||||||
var c = 0;
|
|
||||||
c < this.categories[i].children.length;
|
|
||||||
c++
|
|
||||||
) {
|
|
||||||
formData.append(
|
|
||||||
"categories[" + i + "][children][" + c + "][id]",
|
|
||||||
this.categories[i].children[c].id
|
|
||||||
);
|
|
||||||
formData.append(
|
|
||||||
"categories[" +
|
|
||||||
i +
|
|
||||||
"][children][" +
|
|
||||||
c +
|
|
||||||
"][position]",
|
|
||||||
this.categories[i].children[c].position
|
|
||||||
);
|
|
||||||
formData.append(
|
|
||||||
"categories[" +
|
|
||||||
i +
|
|
||||||
"][children][" +
|
|
||||||
c +
|
|
||||||
"][parent_id]",
|
|
||||||
this.categories[i].children[c].parent_id
|
|
||||||
);
|
|
||||||
if (
|
|
||||||
this.categories[i].children[c].children.length > 0
|
|
||||||
) {
|
|
||||||
for (
|
|
||||||
var w = 0;
|
|
||||||
w <
|
|
||||||
this.categories[i].children[c].children.length;
|
|
||||||
w++
|
|
||||||
) {
|
|
||||||
formData.append(
|
|
||||||
"categories[" +
|
|
||||||
i +
|
|
||||||
"][children][" +
|
|
||||||
c +
|
|
||||||
"][children][" +
|
|
||||||
w +
|
|
||||||
"][id]",
|
|
||||||
this.categories[i].children[c].children[w]
|
|
||||||
.id
|
|
||||||
);
|
|
||||||
formData.append(
|
|
||||||
"categories[" +
|
|
||||||
i +
|
|
||||||
"][children][" +
|
|
||||||
c +
|
|
||||||
"][children][" +
|
|
||||||
w +
|
|
||||||
"][position]",
|
|
||||||
this.categories[i].children[c].children[w]
|
|
||||||
.position
|
|
||||||
);
|
|
||||||
formData.append(
|
|
||||||
"categories[" +
|
|
||||||
i +
|
|
||||||
"][children][" +
|
|
||||||
c +
|
|
||||||
"][children][" +
|
|
||||||
w +
|
|
||||||
"][parent_id]",
|
|
||||||
this.categories[i].children[c].children[w]
|
|
||||||
.parent_id
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const { data } = await axios.post(
|
const { data } = await axios.post(
|
||||||
"/dashboard/categories/position",
|
"/dashboard/categories/position",
|
||||||
formData
|
{
|
||||||
|
categories: this.normalizeTree(this.categoriesData, null, 0),
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (data.status) {
|
if (data.status) {
|
||||||
// window.location.href = "/dashboard/categories";
|
window.location.reload();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
Change() {
|
Change() {
|
||||||
for (var i = 0; i < this.categories.length; i++) {
|
this.normalizeTree(this.categoriesData, null, 0);
|
||||||
var num = i + 1;
|
},
|
||||||
|
|
||||||
this.categories[i].position = num;
|
normalizeTree(categories, parentId, level) {
|
||||||
this.categories[i].droppable = true;
|
return categories.map((category, index) => {
|
||||||
|
category.position = index + 1;
|
||||||
|
category.parent_id = parentId;
|
||||||
|
category.droppable = level < 2;
|
||||||
|
|
||||||
if (this.categories[i].children.length > 0) {
|
const children = Array.isArray(category.children)
|
||||||
for (
|
? this.normalizeTree(category.children, category.id, level + 1)
|
||||||
var c = 0;
|
: [];
|
||||||
c < this.categories[i].children.length;
|
|
||||||
c++
|
|
||||||
) {
|
|
||||||
var numm = c + 1;
|
|
||||||
this.categories[i].children[c].position = numm;
|
|
||||||
this.categories[i].children[c].parent_id =
|
|
||||||
this.categories[i].id;
|
|
||||||
this.categories[i].children[c].droppable = true;
|
|
||||||
|
|
||||||
if (
|
return {
|
||||||
this.categories[i].children[c].children.length > 0
|
id: category.id,
|
||||||
) {
|
position: category.position,
|
||||||
for (
|
parent_id: category.parent_id,
|
||||||
var w = 0;
|
children,
|
||||||
w <
|
};
|
||||||
this.categories[i].children[c].children.length;
|
});
|
||||||
w++
|
|
||||||
) {
|
|
||||||
var nummm = w + 1;
|
|
||||||
|
|
||||||
this.categories[i].children[c].children[
|
|
||||||
w
|
|
||||||
].position = nummm;
|
|
||||||
this.categories[i].children[c].children[
|
|
||||||
w
|
|
||||||
].parent_id = this.categories[i].children[c].id;
|
|
||||||
this.categories[i].children[c].children[
|
|
||||||
w
|
|
||||||
].droppable = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
handleMainCategory() {
|
handleMainCategory() {
|
||||||
if (this.category) {
|
if (this.category) {
|
||||||
this.categories = this.category.children;
|
this.categories = this.category.children;
|
||||||
this.subCategories = this.category.children;
|
this.subCategories = this.category.children;
|
||||||
|
this.currentParentId = this.category.id;
|
||||||
} else {
|
} else {
|
||||||
this.categories = this.categoriesData;
|
this.categories = this.categoriesData;
|
||||||
this.subCategories = null;
|
this.subCategories = null;
|
||||||
|
this.currentParentId = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
handleSubCategory() {
|
handleSubCategory() {
|
||||||
if (this.subCategory) this.categories = this.subCategory.children;
|
if (this.subCategory) {
|
||||||
else this.categories = this.category.children;
|
this.categories = this.subCategory.children;
|
||||||
|
this.currentParentId = this.subCategory.id;
|
||||||
|
} else {
|
||||||
|
this.categories = this.category.children;
|
||||||
|
this.currentParentId = this.category ? this.category.id : null;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -111,7 +111,6 @@
|
|||||||
type="file"
|
type="file"
|
||||||
name="image"
|
name="image"
|
||||||
@change="ImageFile($event)"
|
@change="ImageFile($event)"
|
||||||
onchange="PreviewImage();"
|
|
||||||
/>
|
/>
|
||||||
<label
|
<label
|
||||||
class="custom-file-label"
|
class="custom-file-label"
|
||||||
@@ -126,6 +125,7 @@
|
|||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<img
|
<img
|
||||||
id="uploadPreview"
|
id="uploadPreview"
|
||||||
|
:src="category.imagePreview"
|
||||||
style="
|
style="
|
||||||
width: 300px;
|
width: 300px;
|
||||||
height: auto;
|
height: auto;
|
||||||
@@ -707,6 +707,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
image: null,
|
image: null,
|
||||||
|
imagePreview: null,
|
||||||
},
|
},
|
||||||
|
|
||||||
char: [],
|
char: [],
|
||||||
@@ -798,6 +799,12 @@ export default {
|
|||||||
|
|
||||||
ImageFile(event) {
|
ImageFile(event) {
|
||||||
this.category.image = event.target.files[0];
|
this.category.image = event.target.files[0];
|
||||||
|
|
||||||
|
if (this.category.image) {
|
||||||
|
this.category.imagePreview = URL.createObjectURL(
|
||||||
|
this.category.image
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
addChar() {
|
addChar() {
|
||||||
|
|||||||
@@ -111,7 +111,6 @@
|
|||||||
type="file"
|
type="file"
|
||||||
name="image"
|
name="image"
|
||||||
@change="ImageFile($event)"
|
@change="ImageFile($event)"
|
||||||
onchange="PreviewImage();"
|
|
||||||
/>
|
/>
|
||||||
<label
|
<label
|
||||||
class="custom-file-label"
|
class="custom-file-label"
|
||||||
@@ -811,6 +810,10 @@ export default {
|
|||||||
|
|
||||||
ImageFile(event) {
|
ImageFile(event) {
|
||||||
this.file = event.target.files[0];
|
this.file = event.target.files[0];
|
||||||
|
|
||||||
|
if (this.file) {
|
||||||
|
this.category.image_url = URL.createObjectURL(this.file);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
addChar() {
|
addChar() {
|
||||||
|
|||||||
@@ -309,7 +309,6 @@
|
|||||||
<input
|
<input
|
||||||
class="form-control"
|
class="form-control"
|
||||||
@change="posterFile($event)"
|
@change="posterFile($event)"
|
||||||
onchange="PreviewImage();"
|
|
||||||
type="file"
|
type="file"
|
||||||
id="poster"
|
id="poster"
|
||||||
/>
|
/>
|
||||||
@@ -670,6 +669,7 @@
|
|||||||
:theme="'default'"
|
:theme="'default'"
|
||||||
:multiple="true"
|
:multiple="true"
|
||||||
:deletable="true"
|
:deletable="true"
|
||||||
|
:linkable="true"
|
||||||
:meta="true"
|
:meta="true"
|
||||||
:accept="'image/*'"
|
:accept="'image/*'"
|
||||||
:maxSize="'10MB'"
|
:maxSize="'10MB'"
|
||||||
@@ -679,10 +679,13 @@
|
|||||||
type: 'Invalid file type. Only images or zip Allowed',
|
type: 'Invalid file type. Only images or zip Allowed',
|
||||||
size: 'Files should not exceed 10MB in size',
|
size: 'Files should not exceed 10MB in size',
|
||||||
}"
|
}"
|
||||||
@select="
|
|
||||||
filesSelected($event, index)
|
|
||||||
"
|
|
||||||
@beforedelete="
|
@beforedelete="
|
||||||
|
onBeforeDelete(
|
||||||
|
$event,
|
||||||
|
index
|
||||||
|
)
|
||||||
|
"
|
||||||
|
@delete="
|
||||||
fileDeleted($event, index)
|
fileDeleted($event, index)
|
||||||
"
|
"
|
||||||
v-model="color.screens"
|
v-model="color.screens"
|
||||||
@@ -1352,18 +1355,6 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.products.childrens[i].filesDataForUpload) {
|
|
||||||
for (
|
|
||||||
let f = 0;
|
|
||||||
f < this.products.childrens[i].filesDataForUpload.length;
|
|
||||||
f++
|
|
||||||
) {
|
|
||||||
formData.append(
|
|
||||||
"colors[" + i + "][screens][new_" + f + "][image]",
|
|
||||||
this.products.childrens[i].filesDataForUpload[f].file
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < this.deletes.childrens.length; i++) {
|
for (let i = 0; i < this.deletes.childrens.length; i++) {
|
||||||
@@ -1394,7 +1385,12 @@ export default {
|
|||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
if (error.response) {
|
if (error.response) {
|
||||||
this.error = true;
|
this.error = true;
|
||||||
this.errors = error.response.data.errors;
|
this.errors = error.response.data.errors || {
|
||||||
|
product: [
|
||||||
|
error.response.data.messages ||
|
||||||
|
"Ошибка при сохранении",
|
||||||
|
],
|
||||||
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -1488,26 +1484,19 @@ export default {
|
|||||||
this.products.childrens[index].sizes.splice(indexx, 1);
|
this.products.childrens[index].sizes.splice(indexx, 1);
|
||||||
},
|
},
|
||||||
|
|
||||||
filesSelected: function (filesDataNewlySelected, index) {
|
onBeforeDelete: function (fileData, index) {
|
||||||
let validFilesData = filesDataNewlySelected.filter(
|
const agent = Array.isArray(this.$refs.vueFileAgent)
|
||||||
(fileData) => !fileData.error
|
? this.$refs.vueFileAgent[index]
|
||||||
);
|
: this.$refs.vueFileAgent;
|
||||||
this.products.childrens[index].filesDataForUpload =
|
|
||||||
this.products.childrens[index].filesDataForUpload.concat(
|
if (agent) {
|
||||||
validFilesData
|
agent.deleteFileRecord(fileData);
|
||||||
);
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
fileDeleted: function (fileData, index) {
|
fileDeleted: function (fileData) {
|
||||||
let i = this.products.childrens[index].screens.indexOf(fileData);
|
if (fileData.id && !this.deletes.screens.includes(fileData.id)) {
|
||||||
|
this.deletes.screens.push(fileData.id);
|
||||||
if (i !== -1) {
|
|
||||||
this.products.childrens[index].screens.splice(i, 1);
|
|
||||||
let id = fileData.id ? fileData.id : null;
|
|
||||||
|
|
||||||
if (fileData.id) {
|
|
||||||
this.deletes.screens.push(id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -324,7 +324,6 @@
|
|||||||
<input
|
<input
|
||||||
class="form-control"
|
class="form-control"
|
||||||
@change="posterFile($event)"
|
@change="posterFile($event)"
|
||||||
onchange="PreviewImage();"
|
|
||||||
required
|
required
|
||||||
type="file"
|
type="file"
|
||||||
id="poster"
|
id="poster"
|
||||||
@@ -684,6 +683,7 @@
|
|||||||
:theme="'default'"
|
:theme="'default'"
|
||||||
:multiple="true"
|
:multiple="true"
|
||||||
:deletable="true"
|
:deletable="true"
|
||||||
|
:linkable="true"
|
||||||
:meta="true"
|
:meta="true"
|
||||||
:accept="'image/*'"
|
:accept="'image/*'"
|
||||||
:maxSize="'10MB'"
|
:maxSize="'10MB'"
|
||||||
@@ -693,10 +693,13 @@
|
|||||||
type: 'Invalid file type. Only images or zip Allowed',
|
type: 'Invalid file type. Only images or zip Allowed',
|
||||||
size: 'Files should not exceed 10MB in size',
|
size: 'Files should not exceed 10MB in size',
|
||||||
}"
|
}"
|
||||||
@select="
|
|
||||||
filesSelected($event, index)
|
|
||||||
"
|
|
||||||
@beforedelete="
|
@beforedelete="
|
||||||
|
onBeforeDelete(
|
||||||
|
$event,
|
||||||
|
index
|
||||||
|
)
|
||||||
|
"
|
||||||
|
@delete="
|
||||||
fileDeleted($event, index)
|
fileDeleted($event, index)
|
||||||
"
|
"
|
||||||
v-model="color.screens"
|
v-model="color.screens"
|
||||||
@@ -1278,18 +1281,6 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.product.colors[i].filesDataForUpload) {
|
|
||||||
for (
|
|
||||||
let f = 0;
|
|
||||||
f < this.product.colors[i].filesDataForUpload.length;
|
|
||||||
f++
|
|
||||||
) {
|
|
||||||
formData.append(
|
|
||||||
"colors[" + i + "][screens][new_" + f + "][image]",
|
|
||||||
this.product.colors[i].filesDataForUpload[f].file
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < this.characteristics.length; i++) {
|
for (var i = 0; i < this.characteristics.length; i++) {
|
||||||
@@ -1442,25 +1433,17 @@ export default {
|
|||||||
// this.$refs.vueFileAgent.deleteUpload(this.uploadUrl, this.uploadHeaders, fileData);
|
// this.$refs.vueFileAgent.deleteUpload(this.uploadUrl, this.uploadHeaders, fileData);
|
||||||
// },
|
// },
|
||||||
|
|
||||||
filesSelected: function (filesDataNewlySelected, index) {
|
onBeforeDelete: function (fileData, index) {
|
||||||
var validFilesData = filesDataNewlySelected.filter(
|
const agent = Array.isArray(this.$refs.vueFileAgent)
|
||||||
(fileData) => !fileData.error
|
? this.$refs.vueFileAgent[index]
|
||||||
);
|
: this.$refs.vueFileAgent;
|
||||||
this.product.colors[index].filesDataForUpload =
|
|
||||||
this.product.colors[index].filesDataForUpload.concat(
|
|
||||||
validFilesData
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
fileDeleted: function (fileData, index) {
|
if (agent) {
|
||||||
var i =
|
agent.deleteFileRecord(fileData);
|
||||||
this.product.colors[index].filesDataForUpload.indexOf(fileData);
|
|
||||||
if (i !== -1) {
|
|
||||||
this.product.colors[index].filesDataForUpload.splice(i, 1);
|
|
||||||
} else {
|
|
||||||
this.deleteUploadedFile(fileData);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
fileDeleted: function () {},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -118,6 +118,17 @@
|
|||||||
</li>
|
</li>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@can('view', 'sliders')
|
||||||
|
<li class="nav-item {{ active([route('dashboard.sliders'), route('dashboard.sliders') . '/*']) }}">
|
||||||
|
<a href="{{ route('dashboard.sliders') }}">
|
||||||
|
<i class="feather icon-image"></i>
|
||||||
|
<span class="menu-title">
|
||||||
|
@lang('admin.slider.title')
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
@endcan
|
||||||
|
|
||||||
@can('view', 'users')
|
@can('view', 'users')
|
||||||
<li class="nav-item {{ active([route('dashboard.users'), route('dashboard.users') . '/*']) }}"><a
|
<li class="nav-item {{ active([route('dashboard.users'), route('dashboard.users') . '/*']) }}"><a
|
||||||
href="{{ route('dashboard.users') }}">
|
href="{{ route('dashboard.users') }}">
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
<div id="app">
|
<div id="app">
|
||||||
<product-edit :product="{{ json_encode($product) }}" :brands="{{ json_encode($brands) }}"
|
<product-edit :product="{{ json_encode($product) }}" :brands="{{ json_encode($brands) }}"
|
||||||
:categories="{{ json_encode($categories) }}" :colors="{{ json_encode($colors) }}"
|
:categories="{{ json_encode($categories) }}" :colors="{{ json_encode($colors) }}"
|
||||||
:back-url="{{ json_encode(url()->previous()) }}" :measurement="{{ json_encode($measurement) }}"></product-edit>
|
:back-url="{{ json_encode(route('dashboard.products')) }}" :measurement="{{ json_encode($measurement) }}"></product-edit>
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user