Hello, I have a table called ReserveTable and another table called Fields I want to get the data of the model of the court:
public function reserva(){
return $this->belongsTo('App\ReservaTable','idcanchas', 'idcanchas');
}
in my Controller I have the following:
$cancha = Cancha::where('iduser', $id)->with('reserva')->get();
foreach ($cancha as $item)
{
echo $item->idcanchas . ': <br>';
foreach ($item->reserva as $re)
{
echo $re->start_date . '<br>';
}
}
I want to send it to the view but it throws me the following error:
ErrorException (E_NOTICE) Trying to get property of non-object
but if I do a dd ($ court) I get the following: