59 lines
1.5 KiB
PHP
59 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Modules\Crm\Entities;
|
|
|
|
use App\User;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class CrmPhoneFollowUp extends Model
|
|
{
|
|
protected $table = 'crm_phone_follow_ups';
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
public static function statusDropdown(): array
|
|
{
|
|
return [
|
|
'pending' => __('crm::lang.phone_status_pending'),
|
|
'contacted' => __('crm::lang.phone_status_contacted'),
|
|
'no_answer' => __('crm::lang.phone_status_no_answer'),
|
|
'interested' => __('crm::lang.phone_status_interested'),
|
|
'not_interested' => __('crm::lang.phone_status_not_interested'),
|
|
'converted' => __('crm::lang.phone_status_converted'),
|
|
];
|
|
}
|
|
|
|
public function logs()
|
|
{
|
|
return $this->hasMany(CrmPhoneFollowUpLog::class, 'phone_follow_up_id')->latest();
|
|
}
|
|
|
|
public function assignedUser()
|
|
{
|
|
return $this->belongsTo(User::class, 'assigned_to');
|
|
}
|
|
|
|
public function createdBy()
|
|
{
|
|
return $this->belongsTo(User::class, 'created_by');
|
|
}
|
|
|
|
public function lead()
|
|
{
|
|
return $this->belongsTo(CrmContact::class, 'lead_id');
|
|
}
|
|
|
|
public function company()
|
|
{
|
|
return $this->belongsTo(CrmCompany::class, 'company_id');
|
|
}
|
|
|
|
public function scopeOnlyOwn($query)
|
|
{
|
|
$query->where(function ($qry) {
|
|
$qry->where('crm_phone_follow_ups.assigned_to', auth()->user()->id)
|
|
->orWhere('crm_phone_follow_ups.created_by', auth()->user()->id);
|
|
});
|
|
}
|
|
}
|