<?php

namespace App\Models;

use CodeIgniter\Model;

class TicketM extends Model
{
    protected $table = 'ticket';
    protected $primaryKey = 'id'; // Assuming your primary key field name is 'id'

    protected $allowedFields = ['id', 'kode', 'client_key', 'reference_id', 'date_created', 'notes', 'status_id'];

    public function listticket()
    {
        return $this->select('ticket.*, client.client_name AS client_name')
                    ->join('client', 'client.client_key = ticket.client_Key', 'left') 
                    ->findAll();

       
    }
    public function getDataby($kode)
    {

            if ($kode) {
                return $this->where('kode', $kode)
                ->first();
            } else {
                return $this->orderBy('id', 'DESC')->findAll();
            }

    }

}
