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

Maybe it is a bug on relation language in model BinshopsCategoryTranslation? #93

Open
GeneratorEVil opened this issue Feb 25, 2023 · 0 comments
Labels

Comments

@GeneratorEVil
Copy link

Hello! I want to get all categories by locale. I try to

       $categories = BinshopsCategoryTranslation::whereHas('language', function($q){            
                $q->where('locale', app()->getLocale());            
        })->get();

And get error

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'binshops_languages.lang_id' in 'where clause'

When i change a relation language on model BinshopsCategoryTranslation to

public function language()
    {
        return $this->hasOne(BinshopsLanguage::class,"id","lang_id");
    }

Then i get collection of Categories with name by current locale.

        dd($categories[0]->category_name); // Show name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants