I'm trying to put in a variable all the data I need to make a table, I mean, I have a database with a table of equipment, a table area, and a classification table, I need an area marked with an X the months in which the equipment carries maintenance which is determined by its classification. my idea was to put in an arrangement each team accompanied by an arrangement of 12 spaces that in the positions corresponding to the month it takes maintenance keep an X.
public function index($id)
{
$area=AreaResponsabilidad::find($id);
$equipos=Equipo::all();
$data=$this->planificar($equipos,$area);
return view('reportes.AT3')->with('data',$data);
}
private function planificar($equipos,AreaResponsabilidad $area)
{
foreach ($equipos as $equipo)
{
$con=0;
if ($equipo->area_id==$area->id)
{
$resp[$con++]=['equipo'=>$equipo,'plan'=>$this->planificar_equipo($equipo)];
}
}
return $resp;
}
private function planificar_equipo($equipo)
{
$meses=Clasificacion::find($equipo->clasificacion_id)->meses;
for ($i=1;$i<=12;$i+=$meses)
{
if ($i==8)
{
$i++;
}
else
{
$plan[$i-1]='X';
}
}
return $plan;
}
but em says that when in the view I put for example @foreach($data as $d) {{$d->plan[0]}} @endforeach
Trying to get property of non-object