refactor: replace custom CRM with Monica fork
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s
This commit is contained in:
81
app/Models/Contact/Call.php
Normal file
81
app/Models/Contact/Call.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user