binshops / laravel-blog

Laravel Blog Package/ Laravel CMS. Easiest way to add a blogging system to your Laravel website. Laravel Blog.

Home Page:https://www.binshops.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

GeneratorEVil opened this issue · comments

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