Fix on refreshing description & images from products
This commit is contained in:
@@ -22,7 +22,7 @@ class SpecieController extends Controller
|
||||
|
||||
public function getOptions()
|
||||
{
|
||||
return response()->json(Species::getOptions());
|
||||
return response()->json(['0' => ''] + Species::getOptions());
|
||||
}
|
||||
|
||||
public function create()
|
||||
|
||||
@@ -20,7 +20,7 @@ class VarietyController extends Controller
|
||||
|
||||
public function getOptionsWithSpecie()
|
||||
{
|
||||
return response()->json(Varieties::getOptionsWithSpecie());
|
||||
return response()->json(['0' => ''] + Varieties::getOptionsWithSpecie());
|
||||
}
|
||||
|
||||
public function create()
|
||||
|
||||
@@ -45,8 +45,6 @@ class ArticleController extends Controller
|
||||
public function edit($id)
|
||||
{
|
||||
$data = Articles::getFull($id);
|
||||
// dump($data);
|
||||
// exit;
|
||||
return view('Admin.Shop.Articles.edit', $data);
|
||||
}
|
||||
|
||||
@@ -69,7 +67,8 @@ class ArticleController extends Controller
|
||||
|
||||
public function getProductImages($product_id, $model)
|
||||
{
|
||||
$data = Articles::getInheritedByProduct($product_id, base64_decode($model));
|
||||
$data['article']['product_id'] = $product_id;
|
||||
$data['no_popup'] = false;
|
||||
return view('Admin.Shop.Articles.partials.product.images', $data);
|
||||
}
|
||||
|
||||
|
||||
@@ -101,6 +101,22 @@ class Articles
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getInheritedImagesByProduct($product_id, $product_type)
|
||||
{
|
||||
switch ($product_type) {
|
||||
case 'App\Models\Botanic\Variety':
|
||||
$data['images'] = Varieties::getImages($product_id);
|
||||
break;
|
||||
case 'App\Models\Botanic\Specie':
|
||||
$data['images'] = Species::getImages($product_id);
|
||||
break;
|
||||
case 'App\Models\Shop\Merchandise':
|
||||
$data['images'] = Merchandises::getImages($product_id);
|
||||
break;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getMeta(&$data = [])
|
||||
{
|
||||
$data['products'] = (($data['article']['product_type'] ?? false) == 'App\Models\Botanic\Variety') ? Varieties::getOptionsWithSpecie() : Species::getOptions();
|
||||
|
||||
Reference in New Issue
Block a user