32 lines
679 B
PHP
32 lines
679 B
PHP
<?php
|
|
|
|
namespace App\Repositories\Api\Order;
|
|
|
|
use App\Models\Order;
|
|
use App\Repositories\Api\BaseApiRepository;
|
|
|
|
class OrderRepository extends BaseApiRepository implements OrderRepositoryInterface
|
|
{
|
|
public function getModel()
|
|
{
|
|
return Order::class;
|
|
}
|
|
|
|
public function createItem($orderId, array $data)
|
|
{
|
|
return \App\Models\OrderItem::create(array_merge(
|
|
['order_id' => $orderId],
|
|
$data
|
|
));
|
|
}
|
|
|
|
public function processPayment($order, $method)
|
|
{
|
|
return $order->update([
|
|
'status' => 'paid',
|
|
'payment_method' => $method,
|
|
'paid_at' => now()
|
|
]);
|
|
}
|
|
}
|