<?php

declare(strict_types=1);

namespace App\Models;

class FileContent extends Model
{
    protected ?string $table = 'file_content';

    protected array $fillable = [
        'hashkey',
        'filehash',
        'titlename',
        'description',
        'size_in_bytes',
        'content',
        'filelocation',
        'created_by',
        'updated_by',
        'details',
        'mimetype',
    ];

    protected array $casts = [
        'size_in_bytes' => 'integer',
        'created_by' => 'integer',
        'updated_by' => 'integer',
        'details' => 'array'
    ];

    /**
     * Related file_list records
     */
    public function fileLists()
    {
        return $this->hasMany(FileList::class, 'contentuid');
    }

    public function creator()
    {
        return $this->belongsTo(User::class, 'created_by');
    }

    public function updater()
    {
        return $this->belongsTo(User::class, 'updated_by');
    }
}
