Support the ongoing development of Laravel.io →
posted 10 years ago
Eloquent

The property or inmueble has several photos, I want to access these fotos, are these two the same?, in the second the query is execute every cycle of the loop? First Form

<?php $photos = $inmueble->photos; ?>
@foreach ($photos as $key => $photo)
		<div class="photo-cont {{ ($key === 0) ? 'current' : ''; }}" >
		<img src="{{ $photo->url }}" alt="russia">
		</div>
@endforeach

Second form

@foreach ($inmueble->photos as $key => $photo)
		<div class="photo-cont {{ ($key === 0) ? 'current' : ''; }}" >
		<img src="{{ $photo->url }}" alt="russia">
		</div>
@endforeach
Last updated 2 years ago.
0

Yes. They are both same.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

lu32 lu32 Joined 31 Aug 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.