CRM/backend/app/Models/Company.php

60 خطوط
1.4 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\SoftDeletes;
class Company extends Model
{
use SoftDeletes;
protected $fillable = [
'name', 'normalized_name', 'company_type', 'industry', 'city', 'address',
'website', 'normalized_website', 'description', 'status', 'owner_id', 'created_by',
];
public function owner(): BelongsTo
{
return $this->belongsTo(User::class, 'owner_id');
}
public function contacts(): HasMany
{
return $this->hasMany(Contact::class);
}
public function leads(): HasMany
{
return $this->hasMany(Lead::class);
}
public function deals(): HasMany
{
return $this->hasMany(Deal::class);
}
public function notes(): MorphMany
{
return $this->morphMany(Note::class, 'notable');
}
public function attachments(): MorphMany
{
return $this->morphMany(Attachment::class, 'attachable');
}
public function tasks(): MorphMany
{
return $this->morphMany(Task::class, 'taskable');
}
public function customFieldValues(): MorphMany
{
return $this->morphMany(CustomFieldValue::class, 'fieldable');
}
}