nhance-enrollment/app/Models/ClientBranchModel.php

54 lines
1.4 KiB
PHP
Executable File

<?php
namespace App\Models;
use CodeIgniter\Model;
class ClientBranchModel extends Model
{
protected $table = 'client_branch';
protected $primaryKey = 'id';
protected $allowedFields = [
"id",
"client_id",
"branch_name",
"branch_code",
"city",
"district",
"state",
"created_by",
"updated_by",
"is_active",
"pincode",
"address1",
"address2",
"gst",
"sez",
"units",
"post_branch_id"
];
public function getBranchAndContactByBranchId($branch_id){
return $this->db->table('client_branch')
->select('client_branch.*')
->select('level_contacts.name, level_contacts.email, level_contacts.mobile, level_contacts.designation,')
->join('level_contacts', 'level_contacts.ref_id = client_branch.id')
->where('level_contacts.contact_type', 'client')
->where('client_branch.id', $branch_id)
->get()
->getResult();
}
public function getExisitingUnits(string $client_id,string $client_branch_id)
{
$res = $this->select('client_branch.units')
->where('client_id', $client_id)
->where('id', $client_branch_id)
->find();
//->getResult();
return (json_decode($res[0]['units']));
}
}