[英]Laravel Eloquent where return null
我有與laravel的多語言站點。 我正在為參數傳遞子彈。 從berita傳遞到beritaDetail。 但是它顯示錯誤,並且當dd($ berita)時,只顯示null
$title = "title_".App::getLocale()." as title";
$content = "content_".App::getLocale()." as content";
$slug = "slug_".App::getLocale();
$berita = Report::select("*", "$title", "$content")->where('slug_'.App::getLocale(), $slug)->first();
dd($berita);
$beritaRandom = Report::take(6)->inRandomOrder()->get();
return view('frontend.pages.berita_detail', array('berita' => $berita,
'beritaRandom' => $beritaRandom ));
我期望輸出是$ berita有一個數組,其中包含與子段匹配的字段,而不是null或空數組
$slug = "slug_".App::getLocale();
$berita = Report::select("*", "$title", "$content")->where('slug_'.App::getLocale(), $slug)->first();
您在這里所做的實際上是檢查slug_LOCALE是否等於自身。 因此,在轉儲$berita
時,它會為空。
祝好運
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.