CRM/backend/app/Models/Campaign.php

50 خطوط
1.1 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Campaign extends Model
{
protected $fillable = [
'name',
'description',
'product_service',
'start_date',
'end_date',
'target',
'status',
'sales_script_id',
];
protected function casts(): array
{
return [
'start_date' => 'date',
'end_date' => 'date',
'target' => 'integer',
];
}
public function assignedAgents(): BelongsToMany
{
return $this->belongsToMany(User::class)
->wherePivot('role', 'agent')
->withPivot('role');
}
public function assignedSupervisors(): BelongsToMany
{
return $this->belongsToMany(User::class)
->wherePivot('role', 'supervisor')
->withPivot('role');
}
public function leads(): HasMany
{
return $this->hasMany(Lead::class);
}
}