storage url o'zgartirildi
This commit is contained in:
@@ -13,6 +13,7 @@ use App\Jobs\Dashboard\Category\Store as StoreJob;
|
||||
use App\Jobs\Dashboard\Category\Update as UpdateJob;
|
||||
use App\Models\Characteristic;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class Controller extends ExController
|
||||
@@ -168,29 +169,9 @@ class Controller extends ExController
|
||||
*/
|
||||
public function position_save(Request $request)
|
||||
{
|
||||
foreach ($request->categories as $category) {
|
||||
$cat = Category::find($category['id']);
|
||||
$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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
DB::transaction(function () use ($request) {
|
||||
$this->saveCategoryPositions($request->input('categories', []), null);
|
||||
});
|
||||
|
||||
$this->info(trans('admin.messages.updated'));
|
||||
|
||||
@@ -199,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
|
||||
|
||||
@@ -45,23 +45,22 @@ class Controller extends ExController
|
||||
return view('dashboard.compilations.index', compact('compilations'));
|
||||
}
|
||||
|
||||
// public function store(StoreRequest $request)
|
||||
// {
|
||||
// if ($request->isMethod('get')) {
|
||||
// $this->authorize('create', 'compilations');
|
||||
//
|
||||
//// $this->authorize('content-manager');
|
||||
// $categories = $this->categories->where('parent_id', null)->get();
|
||||
// return view('dashboard.compilations.store', compact('categories'));
|
||||
// }
|
||||
//
|
||||
// $this->dispatchSync(new StoreJob($request));
|
||||
//
|
||||
// $this->success(trans('admin.messages.created'));
|
||||
// return response()->json([
|
||||
// 'status' => true
|
||||
// ]);
|
||||
// }
|
||||
public function store(StoreRequest $request)
|
||||
{
|
||||
if ($request->isMethod('get')) {
|
||||
$this->authorize('create', 'compilations');
|
||||
|
||||
$categories = $this->categories->whereNull('parent_id')->orderBy('position')->get();
|
||||
return view('dashboard.compilations.store', compact('categories'));
|
||||
}
|
||||
|
||||
$this->dispatchSync(new StoreJob($request));
|
||||
|
||||
$this->success(trans('admin.messages.created'));
|
||||
return response()->json([
|
||||
'status' => true
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Compilation $compilation
|
||||
@@ -74,17 +73,20 @@ class Controller extends ExController
|
||||
if ($request->isMethod('get')) {
|
||||
// $this->authorize('content-manager');
|
||||
|
||||
$compilation->loadMissing(['products:id,name,poster']);
|
||||
|
||||
$this->authorize('update', 'compilations');
|
||||
|
||||
foreach ($compilation->products as $product) {
|
||||
$product->poster = '/'. $product->poster;
|
||||
$products = $compilation->dashboardProducts()
|
||||
->select('products.id', 'products.name', 'products.poster')
|
||||
->get();
|
||||
|
||||
foreach ($products as $product) {
|
||||
$product->poster = $product->getPoster();
|
||||
$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'));
|
||||
@@ -104,12 +106,34 @@ class Controller extends ExController
|
||||
*/
|
||||
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 [
|
||||
'id' => $product->id,
|
||||
'poster' => '/' . $product->poster,
|
||||
'poster' => $product->getPoster(),
|
||||
'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
|
||||
|
||||
@@ -283,11 +283,7 @@ class Controller extends ExController
|
||||
foreach ($product->childrens as $children) {
|
||||
foreach ($children->screens as $screen) {
|
||||
$screen->sizeText = $screen->size / 1024 . 'Kb';
|
||||
if (env('FILESYSTEM_DISK') == 's3') {
|
||||
$screen->url = Storage::url($screen->path);
|
||||
} else {
|
||||
$screen->url = '/' . $screen->path;
|
||||
}
|
||||
$screen->type = "image/jpeg";
|
||||
}
|
||||
}
|
||||
@@ -318,15 +314,15 @@ class Controller extends ExController
|
||||
try {
|
||||
$this->dispatchSync(new UpdateJob($product, $request));
|
||||
$this->dispatchSync(new ChildUpdateJob($request, $product));
|
||||
$this->charSync($product, $request->characteristics);
|
||||
$this->dispatchSync(new DeletesJob($request));
|
||||
} catch (Exception $e) {
|
||||
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'));
|
||||
|
||||
return response()->json([
|
||||
@@ -394,11 +390,15 @@ class Controller extends ExController
|
||||
$article_number = empty($request->get('article_number')) ? null : $request->get('article_number');
|
||||
|
||||
if ($category) {
|
||||
$categoryFind = Category::find($category);
|
||||
$categoryFind = Category::withTrashed()->find($category);
|
||||
if ($categoryFind) {
|
||||
list($categoryFind, $category_id) = $this->categoryQuery->getCategoriesAndCategoryMainId($categoryFind);
|
||||
} else {
|
||||
$category_id = [];
|
||||
}
|
||||
} else {
|
||||
$category_id = [];
|
||||
}
|
||||
|
||||
if ($in_stock) {
|
||||
$products = Product::latest('id')->searchFilter($id, $brand, $category, $published, $article_number, $category_id, $name);
|
||||
|
||||
@@ -40,14 +40,14 @@ class Update extends FormRequest
|
||||
return Str::slug($this->get('name')['uz']);
|
||||
}
|
||||
|
||||
public function getImage(Category $category): string
|
||||
public function getImage(Category $category): ?string
|
||||
{
|
||||
if ($this->hasFile('image')) {
|
||||
Storage::delete($category->image);
|
||||
return (string) $this->file('image')->store('uploads/categories');
|
||||
} else {
|
||||
return 'null';
|
||||
}
|
||||
|
||||
return $category->image;
|
||||
}
|
||||
|
||||
public function getFilterPower()
|
||||
|
||||
@@ -22,7 +22,8 @@ class Store extends FormRequest
|
||||
return [
|
||||
'title' => 'array',
|
||||
'title.*' => 'required',
|
||||
'published' => 'required',
|
||||
'published' => 'nullable',
|
||||
'products' => 'nullable|array',
|
||||
//'category_id' => 'required'
|
||||
];
|
||||
}
|
||||
@@ -40,7 +41,7 @@ class Store extends FormRequest
|
||||
*/
|
||||
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()
|
||||
{
|
||||
if ($this->get('category_id')) {
|
||||
$this->get('category_id');
|
||||
if ($this->get('category_id') && $this->get('category_id') != 0) {
|
||||
return $this->get('category_id');
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -22,7 +22,8 @@ class Update extends FormRequest
|
||||
return [
|
||||
'title' => 'array',
|
||||
'title.*' => 'required',
|
||||
'published' => 'required',
|
||||
'published' => 'nullable',
|
||||
'products' => 'nullable|array',
|
||||
//'category_id' => 'required',
|
||||
];
|
||||
}
|
||||
@@ -40,14 +41,14 @@ class Update extends FormRequest
|
||||
*/
|
||||
public function getPublished(): bool
|
||||
{
|
||||
return $this->get('published');
|
||||
return filter_var($this->get('published', false), FILTER_VALIDATE_BOOLEAN);
|
||||
}
|
||||
|
||||
|
||||
public function getCategory()
|
||||
{
|
||||
if ($this->get('category_id')) {
|
||||
$this->get('category_id');
|
||||
if ($this->get('category_id') && $this->get('category_id') != 0) {
|
||||
return $this->get('category_id');
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -35,8 +35,8 @@ class Update
|
||||
$category->name = $request->getName();
|
||||
$category->slug = $request->getSlug();
|
||||
$category->position = $request->getPosition();
|
||||
$category->image = $request->getImage($category);
|
||||
// $category->parent_id = $request->getParentId();
|
||||
$category->image = $this->image;
|
||||
$category->parent_id = $request->getParentId();
|
||||
// $category->popular = $request->getPopular();
|
||||
$category->published = $request->getPublished();
|
||||
$category->is_filter_power = $request->getFilterPower();
|
||||
@@ -45,8 +45,6 @@ class Update
|
||||
$category->keywords = $request->keywords;
|
||||
$category->title_seo = $request->title_seo;
|
||||
|
||||
$category->image = $this->image;
|
||||
|
||||
$category->save();
|
||||
|
||||
if (isset($request->brands)) {
|
||||
|
||||
@@ -36,8 +36,10 @@ class Store
|
||||
|
||||
$map = array_map(function ($product) {
|
||||
return $product['id'];
|
||||
}, $this->request->products);
|
||||
}, $this->request->products ?? []);
|
||||
|
||||
if (!empty($map)) {
|
||||
$compilation->products()->attach($map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,20 +35,12 @@ class Update
|
||||
'category_id' => $this->request->getCategory()
|
||||
]);
|
||||
|
||||
$detach = Compilation::find($this->compilation->id);
|
||||
$detach->loadMissing(['products:id']);
|
||||
|
||||
$compilation = Compilation::find($this->compilation->id);
|
||||
|
||||
$map = array_map(function ($product) {
|
||||
return $product['id'];
|
||||
}, $this->request->products);
|
||||
}, $this->request->products ?? []);
|
||||
|
||||
$detach = array_map(function ($product) {
|
||||
return $product['id'];
|
||||
}, $detach->products->toArray());
|
||||
|
||||
$compilation->products()->detach($detach);
|
||||
$compilation->products()->attach($map);
|
||||
$compilation->products()->sync($map);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,13 +62,8 @@ class Brand extends Model
|
||||
public function getImage(): string
|
||||
{
|
||||
if (!empty($this->image)) {
|
||||
if (in_array(config('filesystems.default'), ['s3', 'minio'])) {
|
||||
return Storage::url($this->image);
|
||||
}
|
||||
;
|
||||
|
||||
return (string) '/' . $this->image;
|
||||
}
|
||||
|
||||
return (string) 'images/no_brend.png';
|
||||
}
|
||||
|
||||
@@ -147,13 +147,9 @@ class Category extends Model
|
||||
public function getImage(): string
|
||||
{
|
||||
if (!in_array($this->image, ['null', null])) {
|
||||
if (in_array(config('filesystems.default'), ['s3', 'minio'])) {
|
||||
return Storage::url($this->image);
|
||||
}
|
||||
|
||||
return config('app.url') . '/' . $this->image;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public function dashboardProducts()
|
||||
{
|
||||
return $this->belongsToMany(Product::class, 'compilation_products');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,12 +30,9 @@ class ContractTemplate extends Model
|
||||
public function full_path(): string
|
||||
{
|
||||
if (!empty($this->path)) {
|
||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
|
||||
return Storage::url($this->path);
|
||||
}
|
||||
return '/' . $this->path;
|
||||
}
|
||||
|
||||
return asset('storage/' . $this->path);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,11 +47,8 @@ class File extends Model
|
||||
public function getPath()
|
||||
{
|
||||
if (!empty($this->path)) {
|
||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
|
||||
return Storage::url($this->path);
|
||||
}
|
||||
return (string) $this->path;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -62,11 +59,8 @@ class File extends Model
|
||||
public function getPathThumb()
|
||||
{
|
||||
if (!empty($this->path_thumb)) {
|
||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
|
||||
return Storage::url($this->path_thumb);
|
||||
}
|
||||
return (string) $this->path_thumb;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -36,13 +36,9 @@ class OrderContract extends Model
|
||||
public function getPath()
|
||||
{
|
||||
if (!empty($this->path)) {
|
||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
|
||||
return Storage::url($this->path);
|
||||
}
|
||||
|
||||
return env('APP_URL') . '/storage/' . $this->path;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,13 +52,9 @@ class Partner extends Model
|
||||
public function getImage(): string
|
||||
{
|
||||
if (!empty($this->image)) {
|
||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
|
||||
return Storage::url($this->image);
|
||||
}
|
||||
|
||||
return (string) $this->image;
|
||||
}
|
||||
|
||||
return (string) 'images/no_brend.png';
|
||||
}
|
||||
|
||||
|
||||
@@ -70,13 +70,9 @@ class PaymentSystemItem extends Model
|
||||
public function getLogo(): string
|
||||
{
|
||||
if (!empty($this->logo)) {
|
||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
|
||||
return Storage::url($this->logo);
|
||||
}
|
||||
|
||||
return env('APP_URL').'/'.$this->logo;
|
||||
}
|
||||
|
||||
return '/images/nophoto.jpg';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,13 +56,9 @@ class Post extends Model
|
||||
public function getImage(): string
|
||||
{
|
||||
if (!empty($this->image)) {
|
||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
|
||||
return Storage::url($this->image);
|
||||
}
|
||||
|
||||
return $this->image;
|
||||
}
|
||||
|
||||
return '/images/nophoto.jpg';
|
||||
}
|
||||
|
||||
|
||||
@@ -236,11 +236,8 @@ class Product extends Model
|
||||
public function getPoster(): string
|
||||
{
|
||||
if (!empty($this->poster)) {
|
||||
if (in_array(config('filesystems.default'), ['s3', 'minio'])) {
|
||||
return Storage::url($this->poster);
|
||||
}
|
||||
return config('app.url') . '/' . $this->poster;
|
||||
}
|
||||
|
||||
return config('app.url') . '/images/no_product.jpg';
|
||||
}
|
||||
@@ -248,22 +245,16 @@ class Product extends Model
|
||||
public function getDataSheet()
|
||||
{
|
||||
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 config('app.url') . '/' . $this->data_sheet;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getPosterThumb(): string
|
||||
{
|
||||
if (!empty($this->poster_thumb)) {
|
||||
if (in_array(config('filesystems.default'), ['s3', 'minio'])) {
|
||||
return Storage::url($this->poster_thumb);
|
||||
}
|
||||
return config('app.url') . '/' . $this->poster_thumb;
|
||||
}
|
||||
|
||||
return config('app.url') . '/images/no_product.jpg';
|
||||
}
|
||||
|
||||
@@ -58,11 +58,8 @@ class Screen extends Model
|
||||
public function getPath(): string
|
||||
{
|
||||
if (!empty($this->path)) {
|
||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
|
||||
return Storage::url($this->path);
|
||||
}
|
||||
return (string) $this->path;
|
||||
}
|
||||
|
||||
return (string) 'image/no_screen.png';
|
||||
}
|
||||
@@ -73,11 +70,8 @@ class Screen extends Model
|
||||
public function getPathThumb(): string
|
||||
{
|
||||
if (!empty($this->path_thumb)) {
|
||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
|
||||
return Storage::url($this->path_thumb);
|
||||
}
|
||||
return (string) $this->path_thumb;
|
||||
}
|
||||
|
||||
return (string) 'image/no_screen_thumb.png';
|
||||
}
|
||||
|
||||
@@ -61,11 +61,8 @@ class Service extends Model
|
||||
public function getImage(): string
|
||||
{
|
||||
if (!empty($this->image)) {
|
||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
|
||||
return Storage::url($this->image);
|
||||
}
|
||||
return (string) $this->image;
|
||||
}
|
||||
|
||||
return (string) 'images/no_brend.png';
|
||||
}
|
||||
|
||||
@@ -45,11 +45,8 @@ class Slider extends Model
|
||||
public function getImage(): string
|
||||
{
|
||||
if (!empty($this->image)) {
|
||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
|
||||
return Storage::url($this->image);
|
||||
}
|
||||
return $this->image;
|
||||
}
|
||||
|
||||
return '/images/nophoto.jpg';
|
||||
}
|
||||
|
||||
@@ -47,11 +47,8 @@ class SpecialOffer extends Model
|
||||
public function getImage(): string
|
||||
{
|
||||
if (!empty($this->image)) {
|
||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
|
||||
return Storage::url($this->image);
|
||||
}
|
||||
return (string) $this->image;
|
||||
}
|
||||
|
||||
return (string) 'images/nophoto.png';
|
||||
}
|
||||
|
||||
@@ -44,11 +44,8 @@ class UsefulInfo extends Model
|
||||
public function getImage(): string
|
||||
{
|
||||
if (!empty($this->image)) {
|
||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
|
||||
return Storage::url($this->image);
|
||||
}
|
||||
return (string) $this->image;
|
||||
}
|
||||
|
||||
return (string) 'images/no_brend.png';
|
||||
}
|
||||
|
||||
@@ -63,11 +63,8 @@ class UsefulInfoItem extends Model
|
||||
public function getFile(): string
|
||||
{
|
||||
if (!empty($this->file_url)) {
|
||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
|
||||
return Storage::url($this->file_url);
|
||||
}
|
||||
return '/' . $this->file_url;
|
||||
}
|
||||
|
||||
return '/images/no_product.jpg';
|
||||
}
|
||||
|
||||
@@ -9,11 +9,13 @@ server {
|
||||
root /quyoshli/public;
|
||||
index index.php;
|
||||
|
||||
# MinIO bucket proxy — serves files over HTTPS
|
||||
location /quyoshli/ {
|
||||
proxy_pass http://quyoshli-minio:9100/quyoshli/;
|
||||
proxy_set_header Host $host;
|
||||
# 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;
|
||||
}
|
||||
|
||||
@@ -22,10 +24,6 @@ server {
|
||||
try_files $uri /$uri /index.php$is_args$args;
|
||||
}
|
||||
|
||||
if (!-e $request_filename) {
|
||||
rewrite ^.*$ /index.php last;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass quyoshli:9000;
|
||||
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="form-group">
|
||||
<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 v-for="category in categories" :value="category.id">
|
||||
{{ category.name.ru }}
|
||||
@@ -194,8 +194,7 @@
|
||||
async SearchProduct(query) {
|
||||
let name = query;
|
||||
|
||||
if (name.length > 0) {
|
||||
axios.post('/dashboard/compilations/product/search', { name: name})
|
||||
axios.post('/dashboard/compilations/product/search', { name: name, category_id: this.category_id})
|
||||
.then((response) => {
|
||||
if (response.data.status) {
|
||||
this.products = response.data.products;
|
||||
@@ -206,7 +205,6 @@
|
||||
this.errors = error.response.data.errors;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
console.log(query);
|
||||
},
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<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 v-for="category in categories" :value="category.id">
|
||||
{{ category.name.ru }}
|
||||
@@ -196,8 +196,7 @@
|
||||
async SearchProduct(query) {
|
||||
let name = query;
|
||||
|
||||
if (name.length > 0) {
|
||||
axios.post('/dashboard/compilations/product/search', { name: name})
|
||||
axios.post('/dashboard/compilations/product/search', { name: name, category_id: this.category_id})
|
||||
.then((response) => {
|
||||
if (response.data.status) {
|
||||
this.products = response.data.products;
|
||||
@@ -208,7 +207,6 @@
|
||||
this.errors = error.response.data.errors;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
console.log(query);
|
||||
},
|
||||
|
||||
@@ -137,168 +137,67 @@ export default {
|
||||
subCategories: [],
|
||||
category: null,
|
||||
subCategory: null,
|
||||
currentParentId: null,
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
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(
|
||||
"/dashboard/categories/position",
|
||||
formData
|
||||
{
|
||||
categories: this.normalizeTree(this.categoriesData, null, 0),
|
||||
}
|
||||
);
|
||||
|
||||
if (data.status) {
|
||||
// window.location.href = "/dashboard/categories";
|
||||
window.location.reload();
|
||||
}
|
||||
},
|
||||
|
||||
Change() {
|
||||
for (var i = 0; i < this.categories.length; i++) {
|
||||
var num = i + 1;
|
||||
this.normalizeTree(this.categoriesData, null, 0);
|
||||
},
|
||||
|
||||
this.categories[i].position = num;
|
||||
this.categories[i].droppable = true;
|
||||
normalizeTree(categories, parentId, level) {
|
||||
return categories.map((category, index) => {
|
||||
category.position = index + 1;
|
||||
category.parent_id = parentId;
|
||||
category.droppable = level < 2;
|
||||
|
||||
if (this.categories[i].children.length > 0) {
|
||||
for (
|
||||
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;
|
||||
const children = Array.isArray(category.children)
|
||||
? this.normalizeTree(category.children, category.id, level + 1)
|
||||
: [];
|
||||
|
||||
if (
|
||||
this.categories[i].children[c].children.length > 0
|
||||
) {
|
||||
for (
|
||||
var w = 0;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
id: category.id,
|
||||
position: category.position,
|
||||
parent_id: category.parent_id,
|
||||
children,
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
handleMainCategory() {
|
||||
if (this.category) {
|
||||
this.categories = this.category.children;
|
||||
this.subCategories = this.category.children;
|
||||
this.currentParentId = this.category.id;
|
||||
} else {
|
||||
this.categories = this.categoriesData;
|
||||
this.subCategories = null;
|
||||
this.currentParentId = null;
|
||||
}
|
||||
},
|
||||
|
||||
handleSubCategory() {
|
||||
if (this.subCategory) this.categories = this.subCategory.children;
|
||||
else this.categories = this.category.children;
|
||||
if (this.subCategory) {
|
||||
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"
|
||||
name="image"
|
||||
@change="ImageFile($event)"
|
||||
onchange="PreviewImage();"
|
||||
/>
|
||||
<label
|
||||
class="custom-file-label"
|
||||
@@ -126,6 +125,7 @@
|
||||
<div class="text-center">
|
||||
<img
|
||||
id="uploadPreview"
|
||||
:src="category.imagePreview"
|
||||
style="
|
||||
width: 300px;
|
||||
height: auto;
|
||||
@@ -707,6 +707,7 @@ export default {
|
||||
},
|
||||
|
||||
image: null,
|
||||
imagePreview: null,
|
||||
},
|
||||
|
||||
char: [],
|
||||
@@ -798,6 +799,12 @@ export default {
|
||||
|
||||
ImageFile(event) {
|
||||
this.category.image = event.target.files[0];
|
||||
|
||||
if (this.category.image) {
|
||||
this.category.imagePreview = URL.createObjectURL(
|
||||
this.category.image
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
addChar() {
|
||||
|
||||
@@ -111,7 +111,6 @@
|
||||
type="file"
|
||||
name="image"
|
||||
@change="ImageFile($event)"
|
||||
onchange="PreviewImage();"
|
||||
/>
|
||||
<label
|
||||
class="custom-file-label"
|
||||
@@ -811,6 +810,10 @@ export default {
|
||||
|
||||
ImageFile(event) {
|
||||
this.file = event.target.files[0];
|
||||
|
||||
if (this.file) {
|
||||
this.category.image_url = URL.createObjectURL(this.file);
|
||||
}
|
||||
},
|
||||
|
||||
addChar() {
|
||||
|
||||
@@ -309,7 +309,6 @@
|
||||
<input
|
||||
class="form-control"
|
||||
@change="posterFile($event)"
|
||||
onchange="PreviewImage();"
|
||||
type="file"
|
||||
id="poster"
|
||||
/>
|
||||
@@ -670,6 +669,7 @@
|
||||
:theme="'default'"
|
||||
:multiple="true"
|
||||
:deletable="true"
|
||||
:linkable="true"
|
||||
:meta="true"
|
||||
:accept="'image/*'"
|
||||
:maxSize="'10MB'"
|
||||
@@ -679,10 +679,13 @@
|
||||
type: 'Invalid file type. Only images or zip Allowed',
|
||||
size: 'Files should not exceed 10MB in size',
|
||||
}"
|
||||
@select="
|
||||
filesSelected($event, index)
|
||||
"
|
||||
@beforedelete="
|
||||
onBeforeDelete(
|
||||
$event,
|
||||
index
|
||||
)
|
||||
"
|
||||
@delete="
|
||||
fileDeleted($event, index)
|
||||
"
|
||||
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++) {
|
||||
@@ -1394,7 +1385,12 @@ export default {
|
||||
.catch((error) => {
|
||||
if (error.response) {
|
||||
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);
|
||||
},
|
||||
|
||||
filesSelected: function (filesDataNewlySelected, index) {
|
||||
let validFilesData = filesDataNewlySelected.filter(
|
||||
(fileData) => !fileData.error
|
||||
);
|
||||
this.products.childrens[index].filesDataForUpload =
|
||||
this.products.childrens[index].filesDataForUpload.concat(
|
||||
validFilesData
|
||||
);
|
||||
onBeforeDelete: function (fileData, index) {
|
||||
const agent = Array.isArray(this.$refs.vueFileAgent)
|
||||
? this.$refs.vueFileAgent[index]
|
||||
: this.$refs.vueFileAgent;
|
||||
|
||||
if (agent) {
|
||||
agent.deleteFileRecord(fileData);
|
||||
}
|
||||
},
|
||||
|
||||
fileDeleted: function (fileData, index) {
|
||||
let i = this.products.childrens[index].screens.indexOf(fileData);
|
||||
|
||||
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);
|
||||
}
|
||||
fileDeleted: function (fileData) {
|
||||
if (fileData.id && !this.deletes.screens.includes(fileData.id)) {
|
||||
this.deletes.screens.push(fileData.id);
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
@@ -324,7 +324,6 @@
|
||||
<input
|
||||
class="form-control"
|
||||
@change="posterFile($event)"
|
||||
onchange="PreviewImage();"
|
||||
required
|
||||
type="file"
|
||||
id="poster"
|
||||
@@ -684,6 +683,7 @@
|
||||
:theme="'default'"
|
||||
:multiple="true"
|
||||
:deletable="true"
|
||||
:linkable="true"
|
||||
:meta="true"
|
||||
:accept="'image/*'"
|
||||
:maxSize="'10MB'"
|
||||
@@ -693,10 +693,13 @@
|
||||
type: 'Invalid file type. Only images or zip Allowed',
|
||||
size: 'Files should not exceed 10MB in size',
|
||||
}"
|
||||
@select="
|
||||
filesSelected($event, index)
|
||||
"
|
||||
@beforedelete="
|
||||
onBeforeDelete(
|
||||
$event,
|
||||
index
|
||||
)
|
||||
"
|
||||
@delete="
|
||||
fileDeleted($event, index)
|
||||
"
|
||||
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++) {
|
||||
@@ -1442,25 +1433,17 @@ export default {
|
||||
// this.$refs.vueFileAgent.deleteUpload(this.uploadUrl, this.uploadHeaders, fileData);
|
||||
// },
|
||||
|
||||
filesSelected: function (filesDataNewlySelected, index) {
|
||||
var validFilesData = filesDataNewlySelected.filter(
|
||||
(fileData) => !fileData.error
|
||||
);
|
||||
this.product.colors[index].filesDataForUpload =
|
||||
this.product.colors[index].filesDataForUpload.concat(
|
||||
validFilesData
|
||||
);
|
||||
},
|
||||
onBeforeDelete: function (fileData, index) {
|
||||
const agent = Array.isArray(this.$refs.vueFileAgent)
|
||||
? this.$refs.vueFileAgent[index]
|
||||
: this.$refs.vueFileAgent;
|
||||
|
||||
fileDeleted: function (fileData, index) {
|
||||
var i =
|
||||
this.product.colors[index].filesDataForUpload.indexOf(fileData);
|
||||
if (i !== -1) {
|
||||
this.product.colors[index].filesDataForUpload.splice(i, 1);
|
||||
} else {
|
||||
this.deleteUploadedFile(fileData);
|
||||
if (agent) {
|
||||
agent.deleteFileRecord(fileData);
|
||||
}
|
||||
},
|
||||
|
||||
fileDeleted: function () {},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -118,6 +118,17 @@
|
||||
</li>
|
||||
@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')
|
||||
<li class="nav-item {{ active([route('dashboard.users'), route('dashboard.users') . '/*']) }}"><a
|
||||
href="{{ route('dashboard.users') }}">
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<div id="app">
|
||||
<product-edit :product="{{ json_encode($product) }}" :brands="{{ json_encode($brands) }}"
|
||||
: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>
|
||||
@endsection
|
||||
|
||||
|
||||
Reference in New Issue
Block a user