1
I have a relationship in Laravel
but when I make an appointment comes the id
and not the name of the field.
Model Evento
public function tipo_evento() {
return $this->hasOne('App\TipoEvento','id','tipo_evento');
}
Model TipoEvento
public function evento() {
return $this->belongsTo('App\Evento');
}
In the controller
$eventos = Evento::with('tipo_evento')->get();
The tables are
Eventos
-id (1)
-nome_evento(blabla)
-tipo_evento(1)
Tipo Evento
-id(1)
-nome(festa)
want to while using $eventos = Evento::with('tipo_evento')->get();
come tipo_evento
party nay 1 how are you coming?
The relationship is wrong
– novic
I thought it would be that way
– Guilherme Freire