Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to retrieve URL morphTo element relationship #24

Closed
justtomisfine opened this issue Jan 3, 2022 · 3 comments
Closed

Unable to retrieve URL morphTo element relationship #24

justtomisfine opened this issue Jan 3, 2022 · 3 comments

Comments

@justtomisfine
Copy link

I'm not able to get products from the URL slug, I believe that this line
https://github.com/getcandy/core/blob/5f11411655869cc9fb5e78b9b42f755f4b814ae6/src/Models/Url.php#L45
would need to be element instead of elements

// With public function elements()
$url->element // returns null
$url->elements // returns null

// With public function element()

$url->element // returns Product or Collection
@glennjacobs
Copy link
Contributor

Looks like that's an issue, we'll look into that tomorrow.

In the meantime, you could look to load via the Product model. See https://laravel.com/docs/8.x/eloquent-relationships#querying-morph-to-relationships

@alecritson
Copy link
Collaborator

This has been updated on the core and scheduled for the next beta release :) Will post here once it's ready to go!

@alecritson
Copy link
Collaborator

We've just pushed out 2.0-beta5 for the admin hub.

This release comes with a few changes, but the most impactful is that we've moved to a monorepo on this repository and the dependency you use has changed.

To get this update you simply need to make a change in your composer file.

From

"getcandy/getcandy": "^2.0"

To

"getcandy/admin": "^2.0"

And then run composer update. In the event that packagist hasn't indexed the update core you may need to run this with the --with-dependencies argument.

Once updated, if you still find this issue persists, feel free to re open and we can take a look :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants