change for description by level of data
This commit is contained in:
@@ -14,6 +14,8 @@ class ArticleController extends Controller
|
|||||||
{
|
{
|
||||||
$data = self::init();
|
$data = self::init();
|
||||||
$data['article'] = Articles::getArticleToSell($id);
|
$data['article'] = Articles::getArticleToSell($id);
|
||||||
|
dump($data);
|
||||||
|
exit;
|
||||||
return view('Shop.Articles.show', $data);
|
return view('Shop.Articles.show', $data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,12 +27,13 @@ class Species
|
|||||||
|
|
||||||
public static function getDescription($id)
|
public static function getDescription($id)
|
||||||
{
|
{
|
||||||
return self::get($id)->description;
|
return self::get($id)->description ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getTags($id)
|
public static function getTags($id)
|
||||||
{
|
{
|
||||||
return self::get($id)->tags->toArray();
|
$model = self::get($id) ?? false;
|
||||||
|
return $model ? $model->tags->toArray() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getFull($id)
|
public static function getFull($id)
|
||||||
@@ -51,7 +52,7 @@ class Species
|
|||||||
|
|
||||||
public static function get($id)
|
public static function get($id)
|
||||||
{
|
{
|
||||||
return Specie::with('tags.tag_group')->findOrFail($id);
|
return Specie::with('tags.tag_group')->find($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function storeFull($data)
|
public static function storeFull($data)
|
||||||
|
|||||||
@@ -46,9 +46,24 @@ class Articles
|
|||||||
return self::getSiblings($id)->pluck('id')->toArray();
|
return self::getSiblings($id)->pluck('id')->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getSiblingsDescriptions($id)
|
||||||
|
{
|
||||||
|
$siblings = self::getSiblings($id);
|
||||||
|
foreach ($siblings as $sibling) {
|
||||||
|
if ($sibling->description && ($sibling->article_nature->name ?? false)) {
|
||||||
|
$data[strtolower($sibling->article_nature->name)] = $sibling->description;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $data ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
public static function getSiblings($id)
|
public static function getSiblings($id)
|
||||||
{
|
{
|
||||||
return Article::with('siblings')->find($id)->siblings;
|
return Article::with([
|
||||||
|
'siblings' => function ($query) use ($id) {
|
||||||
|
$query->where('id', '!=', $id);
|
||||||
|
},
|
||||||
|
])->find($id)->siblings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getOffersById($id)
|
public static function getOffersById($id)
|
||||||
@@ -80,7 +95,7 @@ class Articles
|
|||||||
{
|
{
|
||||||
$article = self::get($id);
|
$article = self::get($id);
|
||||||
$data = $article->toArray();
|
$data = $article->toArray();
|
||||||
$parents = self::getInheritedByProduct($article->product_id, $article->product_type);
|
// $parents = self::getInheritedByProduct($article->product_id, $article->product_type);
|
||||||
$data['description'] = self::getFullDescriptionByArticle($article);
|
$data['description'] = self::getFullDescriptionByArticle($article);
|
||||||
$images = self::getFullImagesByArticle($article);
|
$images = self::getFullImagesByArticle($article);
|
||||||
$data['image'] = self::getPreviewSrc($images[0] ?? false);
|
$data['image'] = self::getPreviewSrc($images[0] ?? false);
|
||||||
@@ -97,23 +112,27 @@ class Articles
|
|||||||
{
|
{
|
||||||
switch ($article->product_type) {
|
switch ($article->product_type) {
|
||||||
case 'App\Models\Botanic\Variety':
|
case 'App\Models\Botanic\Variety':
|
||||||
$variety = $article->product;
|
$data['variety'] = $article->product->description;
|
||||||
$specie = $variety->specie;
|
if ($article->product->specie->description ?? false) {
|
||||||
$description = $specie->description . $variety->description;
|
$data['specie'] = $article->product->specie->description;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'App\Models\Botanic\Specie':
|
case 'App\Models\Botanic\Specie':
|
||||||
$specie = $article->product;
|
$data['specie'] = $article->product->description;
|
||||||
$description = $specie->description;
|
|
||||||
break;
|
break;
|
||||||
case 'App\Models\Shop\Merchandise':
|
case 'App\Models\Shop\Merchandise':
|
||||||
$merchandise = $article->product;
|
$data['merchandise'] = $article->product->description;
|
||||||
$description = $merchandise->description;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$description = '';
|
|
||||||
}
|
}
|
||||||
$description .= $article->description;
|
if ($article->description) {
|
||||||
return $description;
|
$data[strtolower($article->article_nature->name ?? '')] = $article->description;
|
||||||
|
}
|
||||||
|
$siblings = self::getSiblingsDescriptions($article->id);
|
||||||
|
if ($siblings) {
|
||||||
|
array_push($data, $siblings);
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getArticle($id)
|
public static function getArticle($id)
|
||||||
@@ -289,7 +308,7 @@ class Articles
|
|||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $data;
|
return $data ?? [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getInheritedByProduct($product_id, $product_type)
|
public static function getInheritedByProduct($product_id, $product_type)
|
||||||
@@ -409,7 +428,7 @@ class Articles
|
|||||||
|
|
||||||
public static function get($id)
|
public static function get($id)
|
||||||
{
|
{
|
||||||
return Article::find($id);
|
return Article::findOrFail($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getFullImagesByArticleId($id)
|
public static function getFullImagesByArticleId($id)
|
||||||
|
|||||||
@@ -13,7 +13,10 @@
|
|||||||
<div style="max-width: 360px;">
|
<div style="max-width: 360px;">
|
||||||
@include('components.multi-images', ['images' => $article['images']])
|
@include('components.multi-images', ['images' => $article['images']])
|
||||||
</div>
|
</div>
|
||||||
{!! $article['description'] !!}
|
{!! $article['description']['semences'] ?? null !!}
|
||||||
|
{!! $article['description']['plants'] ?? null !!}
|
||||||
|
{!! $article['description']['variety'] ?? null !!}
|
||||||
|
{!! $article['description']['merchandise'] ?? null !!}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-3">
|
<div class="col-3">
|
||||||
@include('Shop.Articles.partials.ArticleAddBasket')
|
@include('Shop.Articles.partials.ArticleAddBasket')
|
||||||
|
|||||||
Reference in New Issue
Block a user