123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?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('created_at', 'desc');
- }
- public function infoLines() {
- return $this->hasMany(ClientInfoLine::class, 'client_id', 'id')->orderBy('created_at', 'desc');
- }
- }
|