<?php

namespace App\Models;

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

class AdVisit extends Model
{
    protected $fillable = [
        'video_id', 'user_id', 'guest_id', 'token',
        'required_seconds', 'clicked_at', 'returned_at', 'valid', 'ip',
    ];

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

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