X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FModels%2FTechnique.php;h=2eb0a941125434b8b68712f11ad3d2c164a08209;hb=7c1db464de8560af8f72228fc311c34f38c1134d;hp=202c455945736ae2107ff21bbd4ce594ade2ccaa;hpb=68aabaf6da8ed6e675bdea728702d5bd75066964;p=alttp.git diff --git a/app/Models/Technique.php b/app/Models/Technique.php index 202c455..2eb0a94 100644 --- a/app/Models/Technique.php +++ b/app/Models/Technique.php @@ -8,4 +8,35 @@ use Illuminate\Database\Eloquent\Model; class Technique extends Model { use HasFactory; + + public function chapters() { + return $this + ->belongsToMany(Technique::class, 'technique_chapter', 'parent_id', 'child_id') + ->withPivot('level', 'order') + ->orderByPivot('order') + ->using(TechniqueChapter::class); + } + + public function relations() { + return $this + ->belongsToMany(Technique::class, 'technique_relations', 'from_id', 'to_id') + ->withPivot('type') + ->using(TechniqueRelation::class); + } + + public function translations() { + return $this->hasMany(TechniqueTranslation::class); + } + + protected $casts = [ + 'index' => 'boolean', + 'requirements' => 'array', + 'rulesets' => 'array', + 'title_icons' => 'array', + ]; + + protected $with = [ + 'translations', + ]; + }