Add new version in repository
This commit is contained in:
@@ -12,87 +12,85 @@ use App\Models\Shop\ArticlePrice;
|
||||
|
||||
class ArticlePrices
|
||||
{
|
||||
public static function getByArticle($id)
|
||||
{
|
||||
return ArticlePrice::byArticle($id)->get();
|
||||
}
|
||||
|
||||
public static function getByArticle($id)
|
||||
{
|
||||
return ArticlePrice::byArticle($id)->get();
|
||||
}
|
||||
public static function getByArticleWithAttribute($id)
|
||||
{
|
||||
return ArticlePrice::with('article_attribute.attribute_value')->byArticle($id)->get();
|
||||
}
|
||||
|
||||
public static function getByArticleWithAttribute($id)
|
||||
{
|
||||
return ArticlePrice::with('article_attribute.attribute_value')->byArticle($id)->get();
|
||||
}
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = ArticlePrice::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = ArticlePrice::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
public static function getAll()
|
||||
{
|
||||
return ArticlePrice::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return ArticlePrice::orderBy('name','asc')->get();
|
||||
}
|
||||
public static function get($id)
|
||||
{
|
||||
return ArticlePrice::find($id);
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return ArticlePrice::find($id);
|
||||
}
|
||||
public static function storePrices($article_id, $prices)
|
||||
{
|
||||
// dump($article_id);
|
||||
// dump($prices);
|
||||
// exit;
|
||||
if ($prices) {
|
||||
foreach ($prices as $key => $price) {
|
||||
$price['article_attribute']['article_attribute_value_id'] = $price['attribute']['attribute_value_id'];
|
||||
$prices[$key]['article_attribute_id'] = ArticleAttributes::storeAttribute($article_id, $price['article_attribute']);
|
||||
|
||||
public static function storePrices($article_id, $prices)
|
||||
{
|
||||
// dump($article_id);
|
||||
// dump($prices);
|
||||
// exit;
|
||||
if ($prices) {
|
||||
foreach ($prices as $key => $price) {
|
||||
$price['article_attribute']['article_attribute_value_id'] = $price['attribute']['attribute_value_id'];
|
||||
$prices[$key]['article_attribute_id'] = ArticleAttributes::storeAttribute($article_id, $price['article_attribute']);
|
||||
unset($prices[$key]['article_attribute']);
|
||||
unset($prices[$key]['attribute']);
|
||||
self::store($prices[$key]);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
unset($prices[$key]['article_attribute']);
|
||||
unset($prices[$key]['attribute']);
|
||||
self::store($prices[$key]);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static function store($data)
|
||||
{
|
||||
$attributes = isset($data['attributes']) ? $data['attributes'] : false;
|
||||
unset($data['attributes']);
|
||||
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$price = $id ? self::update($data) : self::create($data);
|
||||
|
||||
$ret = $attributes ? self::storeAttributes($price->id, $attributes) : false;
|
||||
|
||||
return $price->id;
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$attributes = isset($data['attributes']) ? $data['attributes'] : false;
|
||||
unset($data['attributes']);
|
||||
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$price = $id ? self::update($data) : self::create($data);
|
||||
|
||||
$ret = $attributes ? self::storeAttributes($price->id, $attributes) : false;
|
||||
|
||||
return $price->id;
|
||||
}
|
||||
|
||||
public static function storeAttributes($article_price_id,$attributes)
|
||||
{
|
||||
return ArticleAttributes::storeAttribute($article_price_id, $attributes);
|
||||
}
|
||||
public static function storeAttributes($article_price_id, $attributes)
|
||||
{
|
||||
return ArticleAttributes::storeAttribute($article_price_id, $attributes);
|
||||
}
|
||||
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return ArticlePrice::create($data);
|
||||
}
|
||||
public static function create($data)
|
||||
{
|
||||
return ArticlePrice::create($data);
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$article = ArticlePrice::find($id);
|
||||
$article->update($data);
|
||||
return $article;
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return ArticlePrice::destroy($id);
|
||||
}
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$article = ArticlePrice::find($id);
|
||||
$article->update($data);
|
||||
return $article;
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return ArticlePrice::destroy($id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user