belongsTo(User::class, 'creator_id', 'id'); } public function products() { return $this->morphedByMany(Product::class, 'categorizable'); } public function getCategoryTypeAttribute($value) { switch ($value) { case 0: $category_type = 'محصولات'; break; case 1: $category_type = 'اخبار'; break; case 2: $category_type = 'مطالب'; break; default: $category_type = ''; } return $category_type; } }