2024-05-15 00:31:24 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
2024-05-17 23:54:03 -04:00
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
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\SoftDeletes;
|
|
|
|
|
|
|
|
class ModVersion extends Model
|
|
|
|
{
|
|
|
|
use HasFactory, SoftDeletes;
|
|
|
|
|
|
|
|
protected $fillable = [
|
|
|
|
'mod_id',
|
|
|
|
'version',
|
|
|
|
'description',
|
|
|
|
'spt_version_id',
|
|
|
|
'virus_total_link',
|
|
|
|
'downloads',
|
|
|
|
];
|
|
|
|
|
|
|
|
public function mod(): BelongsTo
|
|
|
|
{
|
|
|
|
return $this->belongsTo(Mod::class);
|
|
|
|
}
|
|
|
|
|
2024-05-17 17:11:54 -04:00
|
|
|
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-17 23:54:03 -04:00
|
|
|
public function scopeLastUpdated(Builder $query): void
|
2024-05-17 17:11:54 -04:00
|
|
|
{
|
2024-05-17 23:54:03 -04:00
|
|
|
$query->orderByDesc('created_at');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function scopeLatestSptVersion(Builder $query): void
|
|
|
|
{
|
|
|
|
$query->orderByDesc(
|
2024-05-17 17:11:54 -04:00
|
|
|
SptVersion::select('spt_versions.version')->whereColumn('mod_versions.spt_version_id', 'spt_versions.id')
|
|
|
|
)->orderByDesc('mod_versions.version');
|
2024-05-15 00:31:24 -04:00
|
|
|
}
|
|
|
|
}
|