fix: prevent error 500 on article pages
This commit is contained in:
@@ -27,21 +27,34 @@ class ArticleTags
|
|||||||
|
|
||||||
switch ($article->product_type) {
|
switch ($article->product_type) {
|
||||||
case 'App\Models\Botanic\Variety':
|
case 'App\Models\Botanic\Variety':
|
||||||
$data += $article->product->tags->toArray();
|
$variety = $article->product;
|
||||||
if ($article->product->specie ?? false) {
|
if ($variety && $variety->tags) {
|
||||||
$data += $article->product->specie->tags->toArray();
|
$data = array_merge($data, $variety->tags->toArray());
|
||||||
|
}
|
||||||
|
if ($variety && $variety->specie && $variety->specie->tags) {
|
||||||
|
$data = array_merge($data, $variety->specie->tags->toArray());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'App\Models\Botanic\Specie':
|
case 'App\Models\Botanic\Specie':
|
||||||
$data += $article->product->tags->toArray();
|
$specie = $article->product;
|
||||||
|
if ($specie && $specie->tags) {
|
||||||
|
$data = array_merge($data, $specie->tags->toArray());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'App\Models\Shop\Merchandise':
|
case 'App\Models\Shop\Merchandise':
|
||||||
$data += $article->product->tags->toArray();
|
$merchandise = $article->product;
|
||||||
$data += $article->product->producer->tags->toArray();
|
if ($merchandise && $merchandise->tags) {
|
||||||
|
$data = array_merge($data, $merchandise->tags->toArray());
|
||||||
|
}
|
||||||
|
if ($merchandise && $merchandise->producer && $merchandise->producer->tags) {
|
||||||
|
$data = array_merge($data, $merchandise->producer->tags->toArray());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
$data += $article->tags->toArray();
|
if ($article->tags) {
|
||||||
|
$data = array_merge($data, $article->tags->toArray());
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($data as $tag) {
|
foreach ($data as $tag) {
|
||||||
if (! isset($tags[$tag['group']][$tag['name']])) {
|
if (! isset($tags[$tag['group']][$tag['name']])) {
|
||||||
|
|||||||
@@ -135,8 +135,11 @@ class Articles
|
|||||||
$data['specie'] = $article->product ? $article->product->description : '';
|
$data['specie'] = $article->product ? $article->product->description : '';
|
||||||
break;
|
break;
|
||||||
case 'App\Models\Shop\Merchandise':
|
case 'App\Models\Shop\Merchandise':
|
||||||
$data['merchandise'] = $article->product ? $article->product->description : '';
|
$merchandise = $article->product;
|
||||||
$data['producer'] = $article->product->producer->description;
|
$data['merchandise'] = $merchandise ? ($merchandise->description ?? '') : '';
|
||||||
|
if ($merchandise && $merchandise->producer) {
|
||||||
|
$data['producer'] = $merchandise->producer->description ?? '';
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user