<?php

namespace App\Apps\Versionmgr\Models;

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

class SkipRecord extends BaseModel
{
    protected $table = 'app_versionmgr_skip_record';

    public const CREATED_AT = 'create_time';

    public const UPDATED_AT = null;

    protected $fillable = [
        'version',
        'build',
        'operator_id',
    ];

    public function operator(): BelongsTo
    {
        return $this->belongsTo(\App\Models\AdminUser::class, 'operator_id');
    }

    public static function isSkipped(string $version, string $build): bool
    {
        return static::where('version', $version)
            ->where('build', $build)
            ->exists();
    }
}
