65 lines
1.5 KiB
PHP
65 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Modules\Crm\Entities;
|
|
|
|
use App\Category;
|
|
use App\User;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class CrmCompany extends Model
|
|
{
|
|
protected $table = 'crm_companies';
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
public static function companyTypes(): array
|
|
{
|
|
return [
|
|
'factory' => __('crm::lang.company_type_factory'),
|
|
'distributor' => __('crm::lang.company_type_distributor'),
|
|
'service' => __('crm::lang.company_type_service'),
|
|
'other' => __('crm::lang.company_type_other'),
|
|
];
|
|
}
|
|
|
|
public function contacts()
|
|
{
|
|
return $this->hasMany(CrmCompanyContact::class, 'company_id');
|
|
}
|
|
|
|
public function branches()
|
|
{
|
|
return $this->hasMany(CrmCompanyBranch::class, 'company_id');
|
|
}
|
|
|
|
public function phones()
|
|
{
|
|
return $this->hasMany(CrmCompanyPhone::class, 'company_id');
|
|
}
|
|
|
|
public function requirements()
|
|
{
|
|
return $this->hasMany(CrmCompanyRequirement::class, 'company_id');
|
|
}
|
|
|
|
public function offers()
|
|
{
|
|
return $this->hasMany(CrmCompanyOffer::class, 'company_id');
|
|
}
|
|
|
|
public function industry()
|
|
{
|
|
return $this->belongsTo(Category::class, 'industry_category_id');
|
|
}
|
|
|
|
public function createdBy()
|
|
{
|
|
return $this->belongsTo(User::class, 'created_by');
|
|
}
|
|
|
|
public function phoneFollowUps()
|
|
{
|
|
return $this->hasMany(CrmPhoneFollowUp::class, 'company_id');
|
|
}
|
|
}
|