El problema que tengo es que el foreach en un controlador (para crear un pdf) y no me funciona
$datos_integrantes = S_Solicitud_Integrante_Persona::where('id_solicitud', '=', $datos->id_solicitud)->get();
escribir($datos, $datos_integrantes));
public function escribir($datos, $integrante)
{
return " <section style='margin-top: 10px;'>
<div align='left'>
<table width='100%'>
@foreach ($integrante as $integrante)
<tr>
<td> ".$integrante->apellido." ".$integrante->nombre." </td>
</tr>
@endforeach
</table> </div> </section>"; }
El error que me tira es: Property [apellido] does not exist on this collection instance. Ahora bien, si utilizo otra variable:
@foreach ($integrante as $inte)
<tr>
<td> ".$inte->apellido." ".$inte->nombre." </td>
</tr>
@endforeach
Dice Undefined variable: inte. Intente hacerlo manualmente, sin usar bucle, y anda:
.$integrante[0]->apellido." ".$integrante[0]->nombre."
.$integrante[1]->apellido." ".$integrante[1]->nombre."
Pero necesito el bucle, y no entiendo por qué el foreach no funciona, nunca me habia pasado! Gracias