nhance/app/Models/ClientRMModel.php
2024-09-13 09:00:09 +05:30

43 lines
1.0 KiB
PHP
Executable File

<?php
namespace App\Models;
use CodeIgniter\Model;
class ClientRMModel extends Model
{
protected $table = 'client_rm';
protected $primaryKey = 'id';
protected $allowedFields = [
"id",
"client_id",
"user_id",
"level",
"created_by",
"updated_by",
"is_active",
];
public function checkExistenceOfClientRelation($id, $user_id, $level)
{
$query = $this->where('client_id', $id)
->where('user_id', $user_id)
->where('level', $level)
->countAllResults();
return ($query > 0) ? true : false;
}
public function getAllClientRM(){
return $this->db->table('client_rm')
->select('client_rm.client_id, client_rm.level,')
->select('user_profiles.first_name as account_manager')
->join('user_profiles', 'user_profiles.id = client_rm.user_id')
->where('level', 3)
->get()
->getResult();
}
}