|
Server : Apache/2.4.41 (Ubuntu) System : Linux vmi1525618.contaboserver.net 5.4.0-105-generic #119-Ubuntu SMP Mon Mar 7 18:49:24 UTC 2022 x86_64 User : www-data ( 33) PHP Version : 8.2.12 Disable Function : NONE Directory : /var/www/erp.theinteractive.co.in/app/Models/ |
Upload File : |
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Lead extends Model
{
protected $fillable = [
'name',
'email',
'subject',
'user_id',
'pipeline_id',
'stage_id',
'sources',
'products',
'notes',
'labels',
'order',
'created_by',
'is_active',
'date',
];
public function labels()
{
if($this->labels)
{
return Label::whereIn('id', explode(',', $this->labels))->get();
}
return false;
}
public function stage()
{
return $this->hasOne('App\Models\LeadStage', 'id', 'stage_id');
}
public function files()
{
return $this->hasMany('App\Models\LeadFile', 'lead_id', 'id');
}
public function pipeline()
{
return $this->hasOne('App\Models\Pipeline', 'id', 'pipeline_id');
}
public function products()
{
if($this->products)
{
return ProductService::whereIn('id', explode(',', $this->products))->get();
}
return [];
}
public function sources()
{
if($this->sources)
{
return Source::whereIn('id', explode(',', $this->sources))->get();
}
return [];
}
public function users()
{
return $this->belongsToMany('App\Models\User', 'user_leads', 'lead_id', 'user_id');
}
public function activities()
{
return $this->hasMany('App\Models\LeadActivityLog', 'lead_id', 'id')->orderBy('id', 'desc');
}
public function discussions()
{
return $this->hasMany('App\Models\LeadDiscussion', 'lead_id', 'id')->orderBy('id', 'desc');
}
public function calls()
{
return $this->hasMany('App\Models\LeadCall', 'lead_id', 'id');
}
public function emails()
{
return $this->hasMany('App\Models\LeadEmail', 'lead_id', 'id')->orderByDesc('id');
}
}