name_last)) $name[] = $this->name_last; if(!empty($this->name_first)) $name[] = $this->name_first; if(!count($name)) { $name = $this->name_display; } else { $name = implode(", ", $name); } return $name; } public function initials() { $characters = []; if(!empty($this->name_first)) $characters[] = $this->name_first[0]; if(!empty($this->name_last)) $characters[] = $this->name_last[0]; return strtolower(implode("", $characters)); } public function cmBills() { return $this->hasMany(Bill::class, 'cm_pro_id'); } public function hcpBills() { return $this->hasMany(Bill::class, 'hcp_pro_id'); } public function lastPayment() { return ProTransaction ::where('pro_id', $this->id) ->where('plus_or_minus', 'PLUS') ->orderBy('created_at', 'desc') ->first(); } public function hasRates() { $numRates = ProRate::where('is_active', true)->where('pro_id', $this->id)->count(); return $numRates > 0; } public function cmRates() { return ProRate::distinct('code') ->where('is_active', true) ->where('pro_id', $this->id) ->where('code', 'LIKE', 'CM%') ->get(); } public function rmRates() { return ProRate::distinct('code') ->where('is_active', true) ->where('pro_id', $this->id) ->where('code', 'LIKE', 'RM%') ->get(); } public function noteRates() { return ProRate::distinct('code') ->where('is_active', true) ->where('pro_id', $this->id) ->where('code', 'NOT LIKE', 'CM%') ->where('code', 'NOT LIKE', 'RM%') ->get(); } public function shortcuts() { return $this->hasMany(ProTextShortcut::class, 'pro_id')->where('is_removed', false); } public function noteTemplates() { return $this->hasMany(NoteTemplatePro::class, 'pro_id') ->where('is_removed', false) ->orderBy('position_index', 'asc'); } public function currentWork() { return ProClientWork::where('pro_id', $this->id)->where('is_active', true)->first(); } public function isWorkingOnClient($_client) { $count = ProClientWork::where('pro_id', $this->id)->where('client_id', $_client->id)->where('is_active', true)->count(); return $count > 0; } public function canvasCustomItems($_key) { return ClientCanvasDataCustomItem::where('key', $_key)->get(); } }