belongsTo(User::class, 'creator_id', 'id'); } public function category() { return $this->morphedByMany('Packages\Product\Models', 'categorizable'); } public function getTypeAttribute($value) { switch ($value) { case 0: $type= 'ساده'; break; case 1: $type= 'متغیر'; break; case 2: $type= 'باندل'; break; default: $type=''; } return $type; } }