5 use Illuminate\Database\Eloquent\Factories\HasFactory;
6 use Illuminate\Database\Eloquent\Model;
7 use Illuminate\Support\Facades\App;
9 class Technique extends Model
13 public function chapters() {
15 ->belongsToMany(Technique::class, 'technique_chapter', 'parent_id', 'child_id')
16 ->withPivot('level', 'order')
17 ->orderByPivot('order')
18 ->using(TechniqueChapter::class);
21 public function relations() {
23 ->belongsToMany(Technique::class, 'technique_relations', 'from_id', 'to_id')
25 ->using(TechniqueRelation::class);
28 public function translations() {
29 return $this->hasMany(TechniqueTranslation::class);
32 public function getTranslatedProperty($prop, $lang = null) {
33 if (is_null($lang)) $lang = App::getLocale();
34 foreach ($this->translations as $translation) {
35 if ($translation->locale == $lang) {
36 return $translation->{$prop};
39 return $this->{$prop};
44 'requirements' => 'array',
45 'rulesets' => 'array',
46 'title_icons' => 'array',