Laravel Eloquent 其中 return 为空
Laravel Eloquent where return null
我有 laravel 的多语言网站。我正在为参数传递 slug。从 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 有一个数组,其中包含与 slug 不为空或空数组匹配的字段
$slug = "slug_".App::getLocale();
$berita = Report::select("*", "$title", "$content")->where('slug_'.App::getLocale(), $slug)->first();
你在这里做的实际上是检查 slug_LOCALE 是否等于它自己。因此在转储 $berita
.
时预计会得到 null
祝你好运
我有 laravel 的多语言网站。我正在为参数传递 slug。从 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 有一个数组,其中包含与 slug 不为空或空数组匹配的字段
$slug = "slug_".App::getLocale();
$berita = Report::select("*", "$title", "$content")->where('slug_'.App::getLocale(), $slug)->first();
你在这里做的实际上是检查 slug_LOCALE 是否等于它自己。因此在转储 $berita
.
祝你好运