[WIP] Finish the order process
This commit is contained in:
@@ -6,31 +6,23 @@ use App\Models\Shop\Order;
|
||||
|
||||
class Orders
|
||||
{
|
||||
public static function getOptions()
|
||||
|
||||
public static function saveOrder($data)
|
||||
{
|
||||
return Order::orderBy('value', 'asc')->get()->pluck('value', 'id')->toArray();
|
||||
$basket = $data['basket'];
|
||||
unset($data['basket']);
|
||||
$order = self::store($data);
|
||||
return $order ? OrderDetails::saveBasket($order->id, $basket) : false;
|
||||
}
|
||||
|
||||
public static function getOptionsByPackage($package_id)
|
||||
public static function get($id, $relations = false)
|
||||
{
|
||||
return Order::byPackage($package_id)->orderBy('value', 'asc')->get()->pluck('value', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Order::orderBy('value', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Order::findOrFail($id);
|
||||
return $relations ? Order::with($relations)->findOrFail($id) : Order::findOrFail($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data, $id) : self::create($data);
|
||||
return $item->id;
|
||||
return ($data['id'] ?? false) ? self::update($data) : self::create($data);
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
@@ -46,7 +38,7 @@ class Orders
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
public static function delete($id)
|
||||
{
|
||||
return Order::destroy($id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user