I'm using the Laravel freamwork where in my database I have 2 tables: - > claimants (with the field 'id', 'claimant', 'type_id') - > types (with the fields 'id', 'name')
Both are already with the Complainant Model Relationship
public function tipoacao(){
return $this->hasMany(TipoAcoes::class, 'id', 'tipoacao_id');
}
Controller:
public function edit($id){
$titulo = "Edita Reclamante";
$reclamantes = $this->reclamante->find($id);
return view('admin.reclamante.create-edit', compact('titulo','reclamantes'));
}
But I'm not able to bring the data with field 'name' of the table 'types' within an imput select
<div class="input-group col-xs-12">
<select class="form-control" id="tipoacao_id" name="tipoacao_id" required value="{{$reclamantes->tipoacao->nome or old('$reclamantes->tipoacao->nome')}}">
@foreach($reclamantes as $Rel)
<option value="{{$Rel->tipoacao->id}}">{{$Rel->tipoacao->nome}}</option>
@endforeach
</select>