<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

#[Fillable([
    'link_id',
    'user_id',
    'ip_hash',
    'country',
    'city',
    'browser',
    'os',
    'device_type',
    'referrer',
    'utm_source',
    'utm_medium',
    'utm_campaign',
    'is_bot',
    'interstitial_token',
    'clicked_at',
])]
class ClickLog extends Model
{
    public $timestamps = false;

    public function link(): BelongsTo
    {
        return $this->belongsTo(Link::class);
    }

    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }

    protected function casts(): array
    {
        return [
            'clicked_at' => 'datetime',
            'is_bot' => 'boolean',
        ];
    }
}
