0
私はこのような2つのクエリを持っている:laravel eloquentは実行前に2つのクエリをマージしますか?
$expiresAt = Carbon::now()->addMinutes(10);
$thumbnails = Cache::remember('entities-thumbnails-'.$entity_id, $expiresAt, function() use ($entity_id) {
return Images::where(['entity_id' => $entity_id, 'image_style' => 'thumbnail'])
->select('path AS thumbnail', 'width As thumbnailWidth', 'height As thumbnailHeight');
});
$largeImages = Cache::remember('entities-largeImages-'.$entity_id, $expiresAt, function() use ($entity_id) {
return Images::where(['entity_id' => $entity_id, 'image_style' => 'large'])
->select('path AS src')
->union($thumbnails)
->get();
});
私は別々が、1つのクエリとしてそれらを実行されていませんやりたいです。全体的に4つのクエリがあるので、代わりに4つのクエリがあります。私は1つを実行したい、それは可能ですか?組合はどのようにして正確に働くのですか?
非常に良い説明です。私はララベルの雄弁にこのようなオプションがあることを知らなかった、私は間違いなく私の質問のほとんどのためにこれを再利用します。ありがとう! – Przemek