php - laravel How to select articles with current language? -
php - laravel How to select articles with current language? -
i'm new laravel , downloaded starter site here, https://github.com/mrakodol/laravel-5-bootstrap-3-starter-site
the site save language in table includes id, lang_code (e.g en), , article database has column "language_id" seems used filtering language. in homecontroller, see line:
$articles = article::with('author')->orderby('position', 'desc')->orderby('created_at', 'desc')->limit(4)->get();
this line select articles , print out without language filter. how can select article in current language?
you can utilize where filtering columns. of course of study depends on kind of id's given languages. need check db.
$articles = article::with('author')->where('language_id',1)->orderby('position', 'desc')->orderby('created_at', 'desc')->limit(4)->get();
php laravel
Comments
Post a Comment