belongsTo('App\BusinessItem', 'element_id')->where('element_type', '=', 'App\BusinessItem'); } public function categories() { return $this->belongsTo('App\BusinessItem', 'element_id')->where('element_type', '=', 'App\Category'); } public function userFrame() { return $this->belongsTo('App\SpUserFrame', 'sp_user_frame_id'); } public function images() { return $this->morphToMany('App\Gallery', 'uploadable')->withPivot('id', 'image_role'); } public function links() { return $this->morphMany('App\SpLink', 'linkable'); } public function getDataAttribute($value) { return json_decode($value, true); } public function getLanguageIdAttribute() { return $this->userFrame->language_id; } public function setDataAttribute($value) { $this->attributes['data'] = json_encode($value, JSON_UNESCAPED_UNICODE); } }