@php $types = [ "Fő fotó", "Hátulja", "Cikkszám", "Csatlakozó", "Futófelület", "További fotó", ]; if( !$item->part->is_required_connector_photo ) { unset($types[3]); } $product_photos = []; foreach($types as $photo_type) { $photo = $photos->where('type', $photo_type)->first(); if( !$photo ) { $photo = new App\Models\Photo; $photo['product_id'] = $item->id; $photo['type'] = $photo_type; } $product_photos[$photo_type] = $photo; } @endphp