82 lines
1.7 KiB
PHP
82 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Contact;
|
|
|
|
use App\Traits\HasUuid;
|
|
use App\Models\Account\Account;
|
|
use App\Models\Instance\Emotion\Emotion;
|
|
use App\Models\ModelBindingWithContact as Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
|
|
/**
|
|
* @property Contact $contact
|
|
*/
|
|
class Call extends Model
|
|
{
|
|
use HasUuid;
|
|
|
|
/**
|
|
* The attributes that aren't mass assignable.
|
|
*
|
|
* @var array<string>|bool
|
|
*/
|
|
protected $guarded = ['id'];
|
|
|
|
/**
|
|
* The attributes that should be mutated to dates.
|
|
*
|
|
* @var array<string>
|
|
*/
|
|
protected $dates = ['called_at'];
|
|
|
|
/**
|
|
* The attributes that should be cast to native types.
|
|
*
|
|
* @var array<string, string>
|
|
*/
|
|
protected $casts = [
|
|
'contact_called' => 'boolean',
|
|
];
|
|
|
|
/**
|
|
* Eager load with every call.
|
|
*/
|
|
protected $with = [
|
|
'account',
|
|
'contact',
|
|
];
|
|
|
|
/**
|
|
* Get the account record associated with the call.
|
|
*
|
|
* @return BelongsTo
|
|
*/
|
|
public function account()
|
|
{
|
|
return $this->belongsTo(Account::class);
|
|
}
|
|
|
|
/**
|
|
* Get the contact record associated with the call.
|
|
*
|
|
* @return BelongsTo
|
|
*/
|
|
public function contact()
|
|
{
|
|
return $this->belongsTo(Contact::class);
|
|
}
|
|
|
|
/**
|
|
* Get the emotion records associated with the call.
|
|
*
|
|
* @return BelongsToMany
|
|
*/
|
|
public function emotions()
|
|
{
|
|
return $this->belongsToMany(Emotion::class, 'emotion_call', 'call_id', 'emotion_id')
|
|
->withPivot('account_id', 'contact_id')
|
|
->withTimestamps();
|
|
}
|
|
}
|