bagisto / headless-ecommerce

Laravel Headless eCommerce APIs allow you to experience seamless and easily scalable storefront performance. An open-source and GraphQL based Rest API Laravel platform delivering ultra-fast, dynamic, and personalized shopping experiences.
https://bagisto.com/en/headless-ecommerce/
MIT License
67 stars 40 forks source link

Getting Errors in Composer while installing headless-ecommerce in a new project. #248

Closed Ticket-Master closed 1 month ago

Ticket-Master commented 2 months ago

Was getting this error after running composer command and it occurs because composer finds the below error as the models in GraphQL folder does not have HasMany relations declared while it is declared in the Models of Webkul package.

Please check below error generated during the installation of headless-ecommerce via composer

Generating optimized autoload files

Illuminate\Foundation\ComposerScripts::postAutoloadDump @php artisan package:discover --ansi

Symfony\Component\ErrorHandler\Error\FatalError

Declaration of Webkul\GraphQLAPI\Models\CatalogRule\CatalogRule::catalog_rule_products() must be compatible with Webkul\CatalogRule\Models\CatalogRule::catalog_rule_products(): Illuminate\Database\Eloquent\Relations\HasMany

at vendor\bagisto\graphql-api\src\Models\CatalogRule\CatalogRule.php:14 10▕ { 11▕ /* 12▕ Get the Catalog rule Product that owns the catalog rule. 13▕ */ ➜ 14▕ public function catalog_rule_products() 15▕ { 16▕ return $this->hasMany(CatalogRuleProductProxy::modelClass()); 17▕ } 18▕

Whoops\Exception\ErrorException

Declaration of Webkul\GraphQLAPI\Models\CatalogRule\CatalogRule::catalog_rule_products() must be compatible with Webkul\CatalogRule\Models\CatalogRule::catalog_rule_products(): Illuminate\Database\Eloquent\Relations\HasMany

at vendor\bagisto\graphql-api\src\Models\CatalogRule\CatalogRule.php:14 10▕ { 11▕ /* 12▕ Get the Catalog rule Product that owns the catalog rule. 13▕ */ ➜ 14▕ public function catalog_rule_products() 15▕ { 16▕ return $this->hasMany(CatalogRuleProductProxy::modelClass()); 17▕ } 18▕

1 vendor\filp\whoops\src\Whoops\Run.php:514 Whoops\Run::handleError("Declaration of Webkul\GraphQLAPI\Models\CatalogRule\CatalogRule::catalog_rule_products() must be compatible with Webkul\CatalogRule\Models\CatalogRule::catalog_rule_products(): Illuminate\Database\Eloquent\Relations\HasMany", "C:\laragon\www\bagisto\vendor\bagisto\graphql-api\src\Models\CatalogRule\CatalogRule.php")

2 [internal]:0 Whoops\Run::handleShutdown()

Just had to add HasMany Relation to the GraphQL API Models CatalogRule in vendor folder.