'array', 'set_products' => 'array']; protected $fillable = [ 'slug', 'headline', 'copy', 'products', 'set_products', ]; public function iq_image() { return $this->belongsTo('App\Models\IqImage', 'iq_image_id'); } public function getLang($key) { $lang = \App::getLocale(); if ($lang == 'de') { return $this->{$key}; } $trans = $this->getTrans($key, $lang); if (!$trans || $trans == '') { return $this->{$key}; } return $trans; } public function getTrans($key, $lang) { $key = 'trans_' . $key; if (!empty($this->{$key}[$lang])) { return $this->{$key}[$lang]; } return ""; } public function getProductModels(){ $ret = []; foreach($this->products as $product_id){ $ret[] = Product::findOrFail($product_id); } return $ret; } public function getProductSetModels(){ $ret = []; foreach($this->set_products as $product_id){ $ret[] = Product::findOrFail($product_id); } return $ret; } public function hasImage(){ if($this->iq_image_id){ if($this->iq_image && isset($this->iq_image->slug) && $this->iq_image->active){ return true; } } return false; } }