Add refreshing for inherited data
This commit is contained in:
@@ -35,7 +35,7 @@ class Articles
|
||||
|
||||
public static function getArticle($id)
|
||||
{
|
||||
$article = Article::with('product.tags')->findOrFail($id);
|
||||
$article = self::get($id);
|
||||
$data = $article->toArray();
|
||||
$data['inherited'] = self::getInherited($id);
|
||||
$data['categories'] = self::getCategoriesNameByArticle($article);
|
||||
@@ -53,7 +53,7 @@ class Articles
|
||||
|
||||
public static function getArticleEdit($id)
|
||||
{
|
||||
$article = Article::with('product.tags')->findOrFail($id);
|
||||
$article = self::get($id);
|
||||
$data = $article->toArray();
|
||||
$data['inherited'] = self::getInherited($id);
|
||||
$data['categories'] = self::getCategoriesByArticle($article);
|
||||
@@ -81,6 +81,26 @@ class Articles
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getInheritedByProduct($product_id, $product_type)
|
||||
{
|
||||
switch ($product_type) {
|
||||
case 'App\Models\Botanic\Variety':
|
||||
$product = Varieties::get($product_id);
|
||||
$data[] = ['name' => 'Espèces', 'description' => Species::getDescription($product->specie_id), 'tags' => Species::getTags($product->specie_id)];
|
||||
$data[] = ['name' => 'Variétés', 'description' => $product->description, 'tags' => $product->tags->toArray()];
|
||||
break;
|
||||
case 'App\Models\Botanic\Specie':
|
||||
$product = Species::get($product_id);
|
||||
$data[] = ['name' => 'Espèces', 'description' => $product->description, 'tags' => $product->tags->toArray()];
|
||||
break;
|
||||
case 'App\Models\Shop\Merchandise':
|
||||
$product = Merchandises::get($product_id);
|
||||
$data[] = ['name' => 'Marchandise', 'description' => $product->description, 'tags' => $product->tags->toArray()];
|
||||
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