I have a problem creating a list of types for my project, for some reason in others Controller
worked perfectly but unfortunately not at this time.
I'm doing the create
method of my Controller
public function create()
{
$celula = new Celula();
$tipos = TipoCelula::where('COD_IDENT_IGREJ', Auth::user()
->COD_IDNET_IGREJ)->lists('TXT_NOMEX_TIPOX','COD_TIPOX_CELUL');
$igreja = Igreja::find(Auth::user()->COD_IDENT_IGREJ);
return view('Celula.cadCelula', compact('celula', 'tipos', 'igreja'));
}
My Type-Cell relationship is as follows, there are several types but each church has its own types so I am selecting only those who have the church code that is consistent with what I am going through, each type of this can be of a cell, but each cell has only one type. Based on this my models
will look like this:
Model Cell
public function tipo(){
return $this->belongsTo('App\TipoCelula', 'COD_TIPOX_CELUL', 'COD_TIPOX_CELUL');
}
Model Type
public function celulas(){
return $this->hasMany('App\Celula', 'COD_TIPOX_CELUL', 'COD_TIPOX_CELUL');
}
With this whole process done in my view I'm trying to list the types as follows:
{!! Form::select('COD_TIPOX_CELUL', $tipos, $celula->COD_TIPOX_CELUL, ['class' => 'form-control', 'placeholder' => 'Selecione uma opção']) !!}
What's going on with my program?