3
I’m having a problem creating a list of types for my project, for some reason in others Controller
worked perfectly but in this unfortunately not.
I’m doing the method create
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 relationship in Type - Cell if as follows, there are several types but each church has its own types so I am selecting only those who have the church code consistent with what I am going through, Each type of this can be from one cell but each cell has only one type of this. Based on this mine models
will stay like this:
Model Celula
public function tipo(){
return $this->belongsTo('App\TipoCelula', 'COD_TIPOX_CELUL', 'COD_TIPOX_CELUL');
}
Model Tipo
public function celulas(){
return $this->hasMany('App\Celula', 'COD_TIPOX_CELUL', 'COD_TIPOX_CELUL');
}
With all this process done in my view I’m trying to list the guys as follows:
{!! Form::select('COD_TIPOX_CELUL', $tipos, $celula->COD_TIPOX_CELUL, ['class' => 'form-control', 'placeholder' => 'Selecione uma opção']) !!}
What’s happening to my program?
As would be my case in the new version ?
– Renan Rodrigues
I made the edition @Renanrodrigues with the code! only really changed the name of the method.
– novic