forge/app/Models/ModDependency.php

56 lines
1.3 KiB
PHP
Raw Permalink Normal View History

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class ModDependency extends Model
{
use HasFactory;
/**
* The relationship between the mod dependency and the mod version.
2024-09-12 13:19:52 -04:00
*
* @return BelongsTo<ModVersion, ModDependency>
*/
public function modVersion(): BelongsTo
{
return $this->belongsTo(ModVersion::class);
}
/**
* The relationship between the mod dependency and the resolved dependency.
2024-09-12 13:19:52 -04:00
*
* @return HasMany<ModResolvedDependency>
*/
public function resolvedDependencies(): HasMany
{
return $this->hasMany(ModResolvedDependency::class, 'dependency_id')
->chaperone();
}
/**
* The relationship between the mod dependency and the dependent mod.
2024-09-12 13:19:52 -04:00
*
* @return BelongsTo<Mod, ModDependency>
*/
public function dependentMod(): BelongsTo
{
return $this->belongsTo(Mod::class, 'dependent_mod_id');
}
2024-10-12 13:18:04 -06:00
/**
* The attributes that should be cast to native types.
*/
protected function casts(): array
{
return [
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
}
}