About the management of international stations
Created 7 years ago by spotony

Hi, Usually, under pryocms. We use the site internationalization, in the absence of the current need to use the language of the case pyrocms use the default language! Now, we need to force changes to the language to choose the content to be presented. For example: I use pyrocms to develop a store, a product only supports a language, in other languages can not see this product. Ask me how to do it? Hope to provide the docs.

ryanthompson  —  7 years ago

If you need to limit content by locale - I would consider adding a simple boolean field that is translatable and work with that.

For example if you have 4 locales enabled and enabled the field value in all but one - you could check the localized value based on the request for that value and decide what to do from there.

Hope that helps!

spotony  —  7 years ago

Thank! This is currently used. Category query:

$relatives = $this->getRelatives();
        return $this->belongsToMany(
                ProductModel::class,
                'stores_products_categories',
                'related_id',
                'entry_id'
            )->wherePivotIn('related_id', $relatives->ids())
            ->leftJoin('stores_products_translations', 'stores_products_translations.entry_id', '=', 'stores_products.id')
            ->where('stores_products_translations.locale', config('app.locale'))
            ->paginate();

Product query:

public function findBySlug($slug)
    {
        return $this->model
            ->where('slug', $slug)
            ->leftJoin('stores_products_translations', 'stores_products_translations.entry_id', '=', 'stores_products.id')
            ->where('stores_products_translations.locale', config('app.locale'))
            ->first();
    }

Will a query can solve the problem? For example, automatic model call a method

ryanthompson  —  7 years ago

You don't need to join translations unless you're filtering by them / need to restrict in the query.

Anyways - I am not sure what you are asking :-/