]> git.localhorst.tv Git - alttp.git/blobdiff - app/Models/Technique.php
tech attribution & requirements
[alttp.git] / app / Models / Technique.php
index 202c455945736ae2107ff21bbd4ce594ade2ccaa..446967125c8e98ebad935fb2a45d20cbeed1ada7 100644 (file)
@@ -8,4 +8,34 @@ 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',
+       ];
+
+       protected $with = [
+               'translations',
+       ];
+
 }