Advertisement
dotphp

query return object

Oct 12th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.10 KB | None | 0 0
  1. $items  = DB::table("calls")->select(DB::raw("calls.*,
  2.                                             sys_rel.rel_to_module as module_name,
  3.                                             sys_rel.rel_to_id as module_id,
  4.                                             (CASE rel_to_module
  5.                                                     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)
  6.                                                 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)
  7.                                                 WHEN sys_rel.rel_to_module = 'org'  THEN ( SELECT org_name FROM org WHERE org.org_serial_id = module_id LIMIT 1)
  8.                                                 WHEN sys_rel.rel_to_module is NULL THEN '-'
  9.                                         END) as calls_parent_id"))
  10.                                             ->leftjoin('sys_rel', 'calls.rel_serial_id', '=', 'sys_rel.rel_serial_id')
  11.                                             ->where('company_id', '=', '1')
  12.                                             ->where('deleted', '=', 0)
  13.                                             ->where('calls.rel_serial_id', '>', 0)
  14.                                             ->having('calls_parent_id', 'LIKE', '%Wehner%')
  15.                                             ->get();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement