use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\App;
class Technique extends Model
{
return $this->hasMany(TechniqueTranslation::class);
}
+ public function getTranslatedProperty($prop, $lang = null) {
+ if (is_null($lang)) $lang = App::getLocale();
+ foreach ($this->translations as $translation) {
+ if ($translation->locale == $lang) {
+ return $translation->{$prop};
+ }
+ }
+ return $this->{$prop};
+ }
+
protected $casts = [
'index' => 'boolean',
'requirements' => 'array',