Skip to content
This repository has been archived by the owner on Jun 18, 2019. It is now read-only.

example in doc for locale filtering in whereTranslation scope #487

Merged
merged 1 commit into from
Jun 27, 2018

Conversation

m13z
Copy link
Contributor

@m13z m13z commented Jun 27, 2018

The whereTranslation scope allows for a third parameter $locale that filters translations in that locale.

I needed that feature to filter slugs in specific locales.

Example:
example.com/map -> map page in english
example.com/sv/karta -> map page in swedish

The problem is that I was querying the pages model using the slug and sv/map would return (correctly) the map page instance, but that's not a correct locale/slug combination.

To make that work using the provided scope it should filter also by locale, which that third parameter enables.

I wasn't aware of it until I went into the source code to try and fix my problem, and the "fix" was already there.

Docs updated so that anybody with the same issue is aware of the option.

The whereTranslation scope allows for a third parameter in the signature.
Added an example in the readme so that reader is aware of it.
@Gummibeer Gummibeer merged commit 5a63ed1 into dimsav:master Jun 27, 2018
@Gummibeer
Copy link
Collaborator

@m13z thanks for this PR!

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

Successfully merging this pull request may close these issues.

2 participants