forge/app/Models/ModVersion.php

55 lines
1.2 KiB
PHP
Raw Normal View History

2024-05-15 00:31:24 -04:00
<?php
namespace App\Models;
use App\Models\Scopes\DisabledScope;
2024-07-26 09:35:09 -04:00
use App\Models\Scopes\PublishedScope;
2024-05-15 00:31:24 -04:00
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
2024-05-15 00:31:24 -04:00
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* @property int $id
* @property int $mod_id
* @property string $version
*/
2024-05-15 00:31:24 -04:00
class ModVersion extends Model
{
use HasFactory, SoftDeletes;
2024-07-20 19:52:36 -04:00
/**
* Post boot method to configure the model.
*/
protected static function booted(): void
{
static::addGlobalScope(new DisabledScope);
2024-07-26 09:35:09 -04:00
static::addGlobalScope(new PublishedScope);
}
2024-07-20 19:52:36 -04:00
/**
* The relationship between a mod version and mod.
*/
2024-05-15 00:31:24 -04:00
public function mod(): BelongsTo
{
return $this->belongsTo(Mod::class);
}
/**
* The relationship between a mod version and its dependencies.
*/
public function dependencies(): HasMany
{
return $this->hasMany(ModDependency::class);
}
2024-07-20 19:52:36 -04:00
/**
* The relationship between a mod version and SPT version.
*/
public function sptVersion(): BelongsTo
2024-05-15 00:31:24 -04:00
{
2024-05-17 17:11:54 -04:00
return $this->belongsTo(SptVersion::class);
}
2024-05-15 00:31:24 -04:00
}