<?php

namespace App\Models;

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

class AffiliateClick extends Model
{
    use HasFactory;

    /**
     * The table only has created_at, no updated_at.
     */
    const UPDATED_AT = null;

    protected $fillable = [
        'affiliate_link_id',
        'ip_address',
        'user_agent',
        'referrer_url',
        'country',
        'is_unique',
    ];

    protected $casts = [
        'is_unique' => 'boolean',
    ];

    /**
     * Get the link this click belongs to.
     */
    public function link()
    {
        return $this->belongsTo(AffiliateLink::class, 'affiliate_link_id');
    }
}
