X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FModels%2FTechnique.php;h=256afc06ea6abe051e47fa08ae39b421e43950f9;hb=9160186db0ea1b0da0edfec49cb3d99ead213bc4;hp=2caa5f320650d296d31d9bbdb0bf6ffbe8e9cbf5;hpb=4ac9a5a331949fcec42378ddc495385ae8628a79;p=alttp.git diff --git a/app/Models/Technique.php b/app/Models/Technique.php index 2caa5f3..256afc0 100644 --- a/app/Models/Technique.php +++ b/app/Models/Technique.php @@ -9,7 +9,24 @@ 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 translations() { + return $this->hasMany(TechniqueTranslation::class); + } + protected $casts = [ 'index' => 'boolean', ]; + + protected $with = [ + 'translations', + ]; + }