12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Relations\HasOne;
- # use Illuminate\Database\Eloquent\Model;
- class Client extends Model
- {
- protected $table = 'client';
- public function displayName() {
- return $this->name_last . ', '. $this->name_first;
- }
- public function mcp() {
- return $this->hasOne(Pro::class, 'id', 'mcp_pro_id');
- }
- public function cm() {
- return $this->hasOne(Pro::class, 'id', 'cm_pro_id');
- }
- public function prosInMeetingWith() {
- return Pro::where('in_meeting_with_client_id', $this->id)->get();
- }
- public function notes() {
- return $this->hasMany(Note::class, 'client_id', 'id')->orderBy('created_at', 'desc');
- }
- public function duplicateOf() {
- return $this->hasOne(Client::class, 'id', 'duplicate_of_client_id');
- }
- public function actionItems () {
- return $this->hasMany(ActionItem::class, 'client_id', 'id')
- ->orderBy('action_item_category', 'asc')
- ->orderBy('created_at', 'desc');
- }
- public function infoLines() {
- return $this->hasMany(ClientInfoLine::class, 'client_id', 'id')->orderBy('created_at', 'desc');
- }
- public function measurements() {
- return $this->hasMany(Measurement::class, 'client_id', 'id')
- ->distinct('label')
- ->where('is_removed', false)
- ->orderBy('label', 'asc')
- ->orderBy('created_at', 'desc');
- }
- public function smses() {
- return $this->hasMany(ClientSMS::class, 'client_id', 'id')
- ->orderBy('created_at', 'desc');
- }
- public function documents() {
- return $this->hasMany(ClientDocument::class, 'client_id', 'id')
- ->orderBy('created_at', 'desc');
- }
- public function smsNumbers() {
- return $this->hasMany(ClientSMSNumber::class, 'client_id', 'id')
- ->orderBy('created_at', 'desc');
- }
- }
|