belongsTo(Category::class); } /** * Get the configurable options of the product. */ public function configOptions(): HasManyThrough { return $this->hasManyThrough(ConfigOption::class, ConfigOptionProduct::class, 'product_id', 'id', 'id', 'config_option_id')->where('config_options.hidden', false)->orderBy('config_options.sort', 'asc')->orderBy('config_options.id', 'desc'); } /** * Get the extension of the product. */ public function server() { return $this->belongsTo(Server::class); } /** * Get all services using this product. */ public function services(): HasMany { return $this->hasMany(Service::class); } /** * Get the settings of the product. */ public function settings(): MorphMany { return $this->morphMany(Setting::class, 'settingable'); } /** * Get all available products upgrades */ public function upgrades() { return $this->belongsToMany(Product::class, 'product_upgrades', 'product_id', 'upgrade_id'); } /** * Gets all upgradable config options for the product. */ public function upgradableConfigOptions(): HasManyThrough { return $this->hasManyThrough(ConfigOption::class, ConfigOptionProduct::class, 'product_id', 'id', 'id', 'config_option_id')->where('config_options.hidden', false)->where('config_options.upgradable', true)->orderBy('config_options.sort', 'asc')->orderBy('config_options.id', 'desc'); } }