the_mechanic/app/Models/VehicleModel.php
2025-02-20 11:33:07 +00:00

24 lines
1.0 KiB
PHP
Executable File

<?php
namespace App\Models;
use CodeIgniter\Model;
class VehicleModel extends Model
{
protected $table = 'vehicle';
protected $primaryKey = 'vehicle_id';
protected $allowedFields = ['branch_id','vehicle_id','make','model','reg_no','year_of_manufacturing','colour','client_id','address','country','state','city','gstnumber','email','postal_code','mobile_no','specific','isactive','updated_by','created_by'];
public function getCustomerandVehicle($branch_id)
{
// Select required fields from both tables
$this->select('vehicle.*, client.client_name ,client.address,client.city,client.state,client.postal_code, make.make as make_name , model.model_name as model_name,model.cubic_capacity_id');
$this->join('client', 'client.client_id = vehicle.client_id');
$this->join('make', 'make.make_id = vehicle.make');
$this->join('model', 'model.model_id = vehicle.model');
$this->where('vehicle.branch_id', $branch_id);
// Get the results
return $this->findAll();
}
}