<?php

namespace App\Models;

use CodeIgniter\Model;

class OrderModel extends Model
{
    protected $table = 'orders';

    protected $allowedFields = [
        'invoice_code',
        'customer_id',
        'user_id',
        'order_date',
        'pickup_date',
        'completed_date',
        'status',
        'total_price',
        'payment_status',
        'payment_method',
        'note'
    ];

    protected $useTimestamps = false;

    // 🔥 Join lengkap (dipakai di API)
    public function getFullOrder($id)
    {
        return $this->select('orders.*, customers.name as customer_name')
            ->join('customers', 'customers.id = orders.customer_id')
            ->where('orders.id', $id)
            ->first();
    }
}