Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var $model_class = 'App\Modules\Calls\Models\Calls';
- -------------------------------------------
- $data = $this->model_class::select(DB::raw($this->table_module.".*,
- sys_rel.rel_to_module as module_name,
- sys_rel.rel_to_id as module_id,
- (CASE rel_to_module
- WHEN sys_rel.rel_to_module = 'leads' THEN ( SELECT CONCAT(leads.leads_first_name, ' ', leads.leads_last_name) FROM leads WHERE leads.leads_serial_id = module_id LIMIT 1)
- WHEN sys_rel.rel_to_module = 'contacts' THEN ( SELECT CONCAT(contacts.contacts_first_name, ' ', contacts.contacts_last_name) FROM contacts WHERE contacts.contacts_serial_id = module_id LIMIT 1)
- WHEN sys_rel.rel_to_module = 'org' THEN ( SELECT org_name FROM org WHERE org.org_serial_id = module_id LIMIT 1)
- WHEN sys_rel.rel_to_module is NULL THEN '-'
- END) as ".$this->table_module."_parent_id"))
- ->leftjoin('sys_rel', 'sys_rel.rel_serial_id', '=', $this->table_module.'.rel_serial_id')
- ->where($this->table_module.'.rel_serial_id', '>', 0)
- ->where('company_id', '=', $company_id)
- ->where('deleted', '=', '0')
- ->orderBy($order_by, $type_sort)
- ->paginate($this->pagesize);
Advertisement
Add Comment
Please, Sign In to add comment