<?php

declare(strict_types=1);

namespace App\Models;

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

class AcademyEvent extends Model
{
    protected $fillable = [
        'event_type',
        'content_type',
        'content_id',
        'user_id',
        'visitor_id',
        'session_id',
        'url',
        'route_name',
        'referrer',
        'utm_source',
        'utm_medium',
        'utm_campaign',
        'device_type',
        'browser',
        'platform',
        'country_code',
        'is_logged_in',
        'is_subscriber',
        'is_admin',
        'is_bot',
        'is_crawler',
        'is_suspicious',
        'metadata',
        'occurred_at',
    ];

    protected $casts = [
        'metadata' => 'array',
        'occurred_at' => 'datetime',
        'is_logged_in' => 'boolean',
        'is_subscriber' => 'boolean',
        'is_admin' => 'boolean',
        'is_bot' => 'boolean',
        'is_crawler' => 'boolean',
        'is_suspicious' => 'boolean',
    ];

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