<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Download extends Model
{
    public $timestamps = false;

    protected $fillable = [
        'user_id', 'license_id', 'product_id', 'product_version_id',
        'ip_address', 'user_agent', 'bytes_transferred', 'completed', 'created_at',
    ];

    protected $casts = [
        'completed' => 'boolean',
        'created_at' => 'datetime',
    ];

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

    public function license()
    {
        return $this->belongsTo(License::class);
    }

    public function product()
    {
        return $this->belongsTo(Product::class);
    }

    public function version()
    {
        return $this->belongsTo(ProductVersion::class, 'product_version_id');
    }
}
