nhance/app/Models/TPABranchModel.php

37 lines
877 B
PHP
Executable File

<?php
namespace App\Models;
use CodeIgniter\Model;
class TPABranchModel extends Model
{
protected $table = 'tpa_branch';
protected $primaryKey = 'id';
protected $allowedFields = [
"id",
"tpa_id",
"branch_name",
"branch_code",
"address1",
"address2",
"city",
"district",
"state",
"pincode",
"created_by",
"updated_by",
"is_active",
];
public function getTpaBranchesWithTpaNames()
{
$query = $this->select('tpa_branch.*, T.short_name as tpa_short_name, T.name as tpa_name')
->join('tpa T', 'tpa_branch.tpa_id = T.id', 'left')
->where('T.is_active', 1)
->where('tpa_branch.is_active', 1)
->find();
return $query;
}
}