<?php

namespace App\Models;

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

class UploadChunk extends Model
{
    protected $fillable = [
        'upload_id',
        'user_id',
        'filename',
        'file_size',
        'chunk_index',
        'total_chunks',
        'chunk_path',
        'chunk_size',
        'expires_at',
    ];

    protected function casts(): array
    {
        return [
            'file_size' => 'integer',
            'chunk_index' => 'integer',
            'total_chunks' => 'integer',
            'chunk_size' => 'integer',
            'expires_at' => 'datetime',
        ];
    }

    /**
     * Get the user that owns the upload chunk.
     */
    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }
}
