<?php

namespace App\Models;

use App\Enums\Status;
use App\Models\BaseModel;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Attachment extends BaseModel
{
    protected $table = 'attachments';

    public const CREATED_AT = 'create_time';

    public const UPDATED_AT = 'update_time';

    protected $fillable = [
        'user_id',
        'name',
        'path',
        'url',
        'mime_type',
        'extension',
        'size',
        'hash',
        'disk',
        'category',
        'group_id',
        'status',
    ];

    protected $casts = [
        'status' => Status::class,
    ];

    public function user(): BelongsTo
    {
        return $this->belongsTo(AdminUser::class, 'user_id');
    }

    public function attachmentGroup(): BelongsTo
    {
        return $this->belongsTo(AttachmentGroup::class, 'group_id');
    }
}
