Add categories for generic prices

This commit is contained in:
Ludovic CANDELLIER
2020-08-31 00:44:29 +02:00
parent 3b6108b449
commit c9198de890
26 changed files with 471 additions and 242 deletions

View File

@@ -36,14 +36,17 @@ class PriceGenerics
public static function get($id)
{
return PriceGeneric::find($id);
return PriceGeneric::with("values")->find($id);
}
public static function store($data)
{
$id = isset($data['id']) ? $data['id'] : false;
$price = $id ? self::update($data) : self::create($data);
return $price->id;
$prices = isset($data['prices']) ? $data['prices'] : false;
unset($data['prices']);
$generic = $id ? self::update($data) : self::create($data);
PriceGenericValues::storePrices($generic->id, $prices);
return $generic->id;
}
public static function create($data)
@@ -54,9 +57,9 @@ class PriceGenerics
public static function update($data, $id = false)
{
$id = isset($data['id']) ? $data['id'] : false;
$article = PriceGeneric::find($id);
$article->update($data);
return $article;
$generic = PriceGeneric::find($id);
$generic->update($data);
return $generic;
}
public static function destroy($id)