There is nothing wrong with those queries. Just make sure you have an index on title.
If you only want one query you can use whereIn('title', ['home1', 'home2', 'homeleft']) and then use this foreach:
$home1 = $home2 = $homeleft = null;
$staticContent = Staticcontent::whereIn('title', ['home1', 'home2', 'homeleft'])->get();
foreach ($staticContent as $content) {
${$content->title} = $content;
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.