<?php

namespace App\Modules\CRM\Models;

use App\Models\User;
use App\Modules\Tenant\Models\Company;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Activity extends Model
{
    use HasFactory;

    protected $table = 'crm_activities';

    protected $fillable = [
        'company_id',
        'lead_id',
        'user_id',
        'type',
        'subject',
        'description',
        'activity_date',
        'next_follow_up_at',
    ];

    protected $casts = [
        'activity_date' => 'date:Y-m-d',
        'next_follow_up_at' => 'date:Y-m-d',
    ];

    /**
     * @return BelongsTo<Company, Activity>
     */
    public function company(): BelongsTo
    {
        return $this->belongsTo(Company::class);
    }

    /**
     * @return BelongsTo<Lead, Activity>
     */
    public function lead(): BelongsTo
    {
        return $this->belongsTo(Lead::class);
    }

    /**
     * @return BelongsTo<User, Activity>
     */
    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }
}
