I have 2 queries like this:
$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();
});
What I want to do is not execute them seperately but as one query. Overall there will be 4 queries therefore instead of doing 4 I want to do one, is that possible? How does union work exactly?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire