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 static function locale2lang($locale) {
14 if (strtolower(substr($locale, 0, 2)) == 'de') return 'de';
18 public function chapters() {
20 ->belongsToMany(Technique::class, 'technique_chapter', 'parent_id', 'child_id')
21 ->withPivot('level', 'order')
22 ->orderByPivot('order')
23 ->using(TechniqueChapter::class);
26 public function relations() {
28 ->belongsToMany(Technique::class, 'technique_relations', 'from_id', 'to_id')
30 ->using(TechniqueRelation::class);
33 public function translations() {
34 return $this->hasMany(TechniqueTranslation::class);
37 public function getTranslatedProperty($prop, $lang = null) {
38 if (is_null($lang)) $lang = App::getLocale();
39 foreach ($this->translations as $translation) {
40 if ($translation->locale == $lang) {
41 return $translation->{$prop};
44 return $this->{$prop};
49 'requirements' => 'array',
50 'rulesets' => 'array',
51 'title_icons' => 'array',