<?php

namespace App\Models;

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

class MarketplaceView extends Model
{
    protected $table = 'marketplace_views';

    protected $fillable = [
        'user_id',
        'package_id',
        'viewed_at',
        'ip_address',
        'user_agent',
        'duration',
    ];

    protected $casts = [
        'viewed_at' => 'datetime',
        'duration' => 'integer',
    ];

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

    public function package(): BelongsTo
    {
        return $this->belongsTo(JobPackage::class, 'package_id');
    }
}