Fixes on attributes on prices
This commit is contained in:
@@ -13,6 +13,11 @@ use App\Models\Shop\ArticlePrice;
|
||||
class ArticlePrices
|
||||
{
|
||||
|
||||
public static function getPricesByArticle($id)
|
||||
{
|
||||
return ArticlePrice::with('ArticleAttributes.Value')->byArticle($id)->get()->toArray();
|
||||
}
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = ArticlePrice::orderBy('name');
|
||||
@@ -65,9 +70,12 @@ class ArticlePrices
|
||||
return ArticlePrice::create($data);
|
||||
}
|
||||
|
||||
public static function update($data)
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
return ArticlePrice::find($id)->update($data);
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$article = ArticlePrice::find($id);
|
||||
$article->update($data);
|
||||
return $article;
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
|
||||
@@ -30,11 +30,12 @@ class Articles
|
||||
$data = $article->toArray();
|
||||
$data['categories'] = self::getCategoriesByArticle($article);
|
||||
$data['tags'] = self::getTagsByArticle($article);
|
||||
$data = self::getMeta($data);
|
||||
$data['prices'] = self::getPricesByArticle($article);
|
||||
self::getMeta($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getMeta($data = [])
|
||||
public static function getMeta(&$data = [])
|
||||
{
|
||||
$data['categories_options'] = Categories::getOptions();
|
||||
$data['families_options'] = ArticleFamilies::getOptions();
|
||||
@@ -55,6 +56,11 @@ class Articles
|
||||
return $article->tags->pluck('id')->toArray();
|
||||
}
|
||||
|
||||
public static function getPricesByArticle($article)
|
||||
{
|
||||
return ArticlePrices::getPricesByArticle($article->id);
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Article::find($id);
|
||||
|
||||
Reference in New Issue
Block a user