Fix on preview mode
This commit is contained in:
@@ -23,44 +23,60 @@ class Articles
|
||||
return $export;
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Article::orderBy('name','asc')->pluck('name','id')->toArray();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Article::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function getFull($id)
|
||||
public static function getArticle($id)
|
||||
{
|
||||
$article = Article::with('product.tags')->findOrFail($id);
|
||||
$data['article'] = $article->toArray();
|
||||
$data['article']['inherited'] = self::getInherited($id);
|
||||
// dump($data);
|
||||
// exit;
|
||||
$data['article']['categories'] = self::getCategoriesByArticle($article);
|
||||
$data['article']['tags'] = self::getTagsByArticle($article);
|
||||
// $data['article']['prices'] = self::getPricesByArticle($article);
|
||||
|
||||
// $data['datatables']['comments'] = Comments::getDatatable();
|
||||
$data['article']['comments'] = $article->comments;
|
||||
$data = $article->toArray();
|
||||
$data['inherited'] = self::getInherited($id);
|
||||
$data['categories'] = self::getCategoriesNameByArticle($article);
|
||||
$data['tags'] = self::getTagsNameByArticle($article);
|
||||
$data['comments'] = Comments::getByModel($article);
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getFull($id)
|
||||
{
|
||||
$data = self::getArticleEdit($id);
|
||||
self::getMeta($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getArticleEdit($id)
|
||||
{
|
||||
$article = Article::with('product.tags')->findOrFail($id);
|
||||
$data = $article->toArray();
|
||||
$data['inherited'] = self::getInherited($id);
|
||||
$data['categories'] = self::getCategoriesByArticle($article);
|
||||
$data['tags'] = self::getTagsByArticle($article);
|
||||
$data['comments'] = Comments::getByModel($article);
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getInherited($id)
|
||||
{
|
||||
$article = Article::with('product.tags')->findOrFail($id);
|
||||
$product_type = $article->product_type;
|
||||
switch ($product_type) {
|
||||
case 'App\Models\Botanic\Variety':
|
||||
$data[] = ['name' => 'Espèces', 'description' => Species::getDescription($article->product->specie_id), 'tags' => Species::getTags($article->product->specie_id)];
|
||||
$data[] = ['name' => 'Variétés', 'description' => $article->product->description, 'tags' => $article->product->tags->toArray()];
|
||||
break;
|
||||
case 'App\Models\Botanic\Specie':
|
||||
$data[] = ['name' => 'Espèces', 'description' => $article->product->description, 'tags' => $article->product->tags->toArray()];
|
||||
break;
|
||||
case 'App\Models\Shop\Merchandise':
|
||||
$data[] = ['name' => 'Marchandise', 'description' => $article->product->description, 'tags' => $article->product->tags->toArray()];
|
||||
break;
|
||||
case 'App\Models\Botanic\Variety':
|
||||
$data[] = ['name' => 'Espèces', 'description' => Species::getDescription($article->product->specie_id), 'tags' => Species::getTags($article->product->specie_id)];
|
||||
$data[] = ['name' => 'Variétés', 'description' => $article->product->description, 'tags' => $article->product->tags->toArray()];
|
||||
break;
|
||||
case 'App\Models\Botanic\Specie':
|
||||
$data[] = ['name' => 'Espèces', 'description' => $article->product->description, 'tags' => $article->product->tags->toArray()];
|
||||
break;
|
||||
case 'App\Models\Shop\Merchandise':
|
||||
$data[] = ['name' => 'Marchandise', 'description' => $article->product->description, 'tags' => $article->product->tags->toArray()];
|
||||
break;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
@@ -86,11 +102,21 @@ class Articles
|
||||
return $article->categories->pluck('id')->toArray();
|
||||
}
|
||||
|
||||
public static function getCategoriesNameByArticle($article)
|
||||
{
|
||||
return $article->categories->pluck('name', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getTagsByArticle($article)
|
||||
{
|
||||
return $article->tags->pluck('id')->toArray();
|
||||
}
|
||||
|
||||
public static function getTagsNameByArticle($article)
|
||||
{
|
||||
return $article->tags->pluck('name', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getPricesByArticle($article)
|
||||
{
|
||||
return Prices::getByArticle($article->id);
|
||||
|
||||
Reference in New Issue
Block a user