<?php

namespace App\Models;

use CodeIgniter\Model;

class BusModel extends Model
{
    protected $table      = 'c_bus';
    protected $primaryKey = 'bus_id';

    protected $allowedFields = [
        'plan_id',
        'from',
        'to',
        'date',
        'time',
        'comments',
        'created_by',
        'updated_by',
        'is_active'
    ];

    protected $useTimestamps = false;
    protected $createdField  = 'created_on';
    protected $updatedField  = 'updated_on';

    /**
     * Get active bus bookings
     */
    public function getActiveBuses()
    {
        return $this->where('is_active', 1)->findAll();
    }

    /**
     * Get bus bookings for a specific plan
     */
    public function getBusesByPlan($planId)
    {
        return $this->where('plan_id', $planId)->findAll();
    }
}
