test
This commit is contained in:
@@ -84,25 +84,29 @@ class Controller extends ExController
|
||||
$this->authorize('create', 'products');
|
||||
$categories = $this->categories->select('id', 'name->ru as category')
|
||||
->where('parent_id', null)
|
||||
->with(['parents' => function ($parent) {
|
||||
return $parent->select('id', 'name->ru as category', 'parent_id')->with(['parents' => function ($parent) {
|
||||
return $parent->select('id', 'name->ru as category', 'parent_id');
|
||||
}]);
|
||||
}])->get();
|
||||
->with([
|
||||
'parents' => function ($parent) {
|
||||
return $parent->select('id', 'name->ru as category', 'parent_id')->with([
|
||||
'parents' => function ($parent) {
|
||||
return $parent->select('id', 'name->ru as category', 'parent_id');
|
||||
}
|
||||
]);
|
||||
}
|
||||
])->get();
|
||||
$brands = $this->brands->get();
|
||||
$colors = $this->colors->get();
|
||||
$measurement = Measurement::query()->get();
|
||||
|
||||
return view('dashboard.products.store', compact('categories', 'brands', 'colors', 'measurement'));
|
||||
}
|
||||
|
||||
|
||||
$product = $this->dispatchSync(StoreJob::fromRequest($request));
|
||||
|
||||
$product->categories()->attach([$request->getCategoryID()]);
|
||||
|
||||
$this->charSync($product, $request->characteristics);
|
||||
$this->dispatchSync(new ChildJob($request, $product));
|
||||
|
||||
|
||||
$this->success(trans('admin.messages.created'));
|
||||
|
||||
return response()->json([
|
||||
@@ -254,15 +258,23 @@ class Controller extends ExController
|
||||
]);
|
||||
},
|
||||
'categories' => function ($categories) {
|
||||
return $categories->select('id', 'name->ru as category', 'parent_id')->with(['parent' => function ($parent) {
|
||||
return $parent->select('id', 'name->ru as category', 'parent_id')->with(['parents', 'parent' => function ($parent) {
|
||||
return $parent->select('id', 'name->ru as category', 'parent_id')->with(['parents' => function ($parent) {
|
||||
return $parent->select('id', 'name->ru as category', 'parent_id');
|
||||
}]);
|
||||
}, 'parents' => function ($parent) {
|
||||
return $parent->select('id', 'name->ru as category', 'parent_id');
|
||||
}]);
|
||||
}]);
|
||||
return $categories->select('id', 'name->ru as category', 'parent_id')->with([
|
||||
'parent' => function ($parent) {
|
||||
return $parent->select('id', 'name->ru as category', 'parent_id')->with([
|
||||
'parents',
|
||||
'parent' => function ($parent) {
|
||||
return $parent->select('id', 'name->ru as category', 'parent_id')->with([
|
||||
'parents' => function ($parent) {
|
||||
return $parent->select('id', 'name->ru as category', 'parent_id');
|
||||
}
|
||||
]);
|
||||
},
|
||||
'parents' => function ($parent) {
|
||||
return $parent->select('id', 'name->ru as category', 'parent_id');
|
||||
}
|
||||
]);
|
||||
}
|
||||
]);
|
||||
},
|
||||
|
||||
'characteristics'
|
||||
@@ -271,19 +283,30 @@ class Controller extends ExController
|
||||
foreach ($product->childrens as $children) {
|
||||
foreach ($children->screens as $screen) {
|
||||
$screen->sizeText = $screen->size / 1024 . 'Kb';
|
||||
$screen->url = $screen->getPath();
|
||||
if (env('FILESYSTEM_DISK') == 's3') {
|
||||
$screen->url = Storage::temporaryUrl(
|
||||
$screen->path,
|
||||
Date::now()->addMinutes(5)
|
||||
);
|
||||
} else {
|
||||
$screen->url = '/' . $screen->path;
|
||||
}
|
||||
$screen->type = "image/jpeg";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$categories = $this->categories->select('id', 'name->ru as category')
|
||||
->where('parent_id', null)
|
||||
->with(['parents' => function ($parent) {
|
||||
return $parent->select('id', 'name->ru as category', 'parent_id')->with(['parents' => function ($parent) {
|
||||
return $parent->select('id', 'name->ru as category', 'parent_id');
|
||||
}]);
|
||||
}])->get();
|
||||
->with([
|
||||
'parents' => function ($parent) {
|
||||
return $parent->select('id', 'name->ru as category', 'parent_id')->with([
|
||||
'parents' => function ($parent) {
|
||||
return $parent->select('id', 'name->ru as category', 'parent_id');
|
||||
}
|
||||
]);
|
||||
}
|
||||
])->get();
|
||||
|
||||
$brands = $this->brands->get();
|
||||
$measurement = Measurement::query()->get();
|
||||
@@ -294,11 +317,11 @@ class Controller extends ExController
|
||||
|
||||
return view('dashboard.products.update', compact('categories', 'brands', 'colors', 'product', 'measurement'));
|
||||
}
|
||||
|
||||
try{
|
||||
|
||||
try {
|
||||
$this->dispatchSync(new UpdateJob($product, $request));
|
||||
$this->dispatchSync(new ChildUpdateJob($request, $product));
|
||||
}catch(Exception $e){
|
||||
} catch (Exception $e) {
|
||||
return Response::json([
|
||||
"messages" => $e->getMessage()
|
||||
]);
|
||||
@@ -410,13 +433,8 @@ class Controller extends ExController
|
||||
*/
|
||||
public function delete_screen(Screen $screen)
|
||||
{
|
||||
if (is_file($screen->path)) {
|
||||
unlink($screen->path);
|
||||
}
|
||||
|
||||
if (is_file($screen->path_thumb)) {
|
||||
unlink($screen->path_thumb);
|
||||
}
|
||||
Storage::delete($screen->path);
|
||||
Storage::delete($screen->path_thumb);
|
||||
|
||||
$screen->delete();
|
||||
|
||||
@@ -434,9 +452,9 @@ class Controller extends ExController
|
||||
'file' => 'required|mimes:xlsx,xls'
|
||||
]);
|
||||
|
||||
$file = $request->file('file')->store('uploads/imports');
|
||||
$file = $request->file('file')->store('uploads/imports', 'local');
|
||||
|
||||
$excel = Excel::toArray(new MobileImport, $file);
|
||||
$excel = Excel::toArray(new MobileImport, storage_path('app/' . $file));
|
||||
|
||||
$excel = collect($excel)->flatten(1)->map(function ($product) {
|
||||
if ($product[0] != null) {
|
||||
|
||||
Reference in New Issue
Block a user