<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class EmailCampaignClick extends Model
{
    use HasFactory;

    protected $fillable = ['recipient_id', 'link_id', 'ip', 'user_agent', 'clicked_at'];

    protected $casts = ['clicked_at' => 'datetime'];

    public function recipient(): BelongsTo
    {
        return $this->belongsTo(EmailCampaignRecipient::class, 'recipient_id');
    }

    public function link(): BelongsTo
    {
        return $this->belongsTo(EmailCampaignLink::class, 'link_id');
    }
}
