<?php

namespace App\Models\Document;

use App\Casts\FileSize;
use App\Models\User\User;
use App\Trait\BelongsToSolicitor;
use Illuminate\Database\Eloquent\Model;

class Document extends Model {
    protected $table = 'documents';
    protected $fillable = [
        'solicitor_id',
        'user_id',
        'display_name',
        'file_name',
        'file_type',
        'file_size',
        'type_id',
    ];

    protected $casts = [
        'file_size' => FileSize::class,
    ];

    use BelongsToSolicitor;

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

    public function type() {
        return $this->belongsTo(DocumentType::class);
    }

    public function owner() {
        return $this->morphTo();
    }
}
