repo_pattern/app/Repositories/OrderRepository.php

40 lines
790 B
PHP
Raw Permalink Normal View History

2024-02-13 07:26:11 +00:00
<?php
namespace App\Repositories;
use App\Interfaces\OrderRepositoryInterface;
use App\Models\Order;
class OrderRepository implements OrderRepositoryInterface
{
public function getAllOrders()
{
return Order::all();
}
public function getOrderById($orderId)
{
return Order::findOrFail($orderId);
}
public function deleteOrder($orderId)
{
Order::destroy($orderId);
}
public function createOrder(array $orderDetails)
{
return Order::create($orderDetails);
}
public function updateOrder($orderId, array $newDetails)
{
return Order::whereId($orderId)->update($newDetails);
}
public function getFulfilledOrders()
{
return Order::where('is_fulfilled', true);
}
}