Call to undefined method Illuminate \ Database \ Query \ Builder :: lists ()

3

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?

    
asked by anonymous 29.09.2016 / 01:48

1 answer

2

The lists method is obsoleta ( deprecated ) and has been replaced by pluck second Upgrading To 5.2.0 From 5.1 , and 5.3 has been removed. In fact there was only one change in the name the rest is equal to the previous lists .

Deprecations

The following features are deprecated in 5.2 and will be removed in the 5.3 release in June 2016:

  
  • Illuminate \ Contracts \ Bus \ SelfHandling contract. Can be removed from jobs.
  •   
  • The lists method on the Collection, query builder and Eloquent query builder objects have been renamed to pluck. The method signature   remains the same.
  •   
  • Implicit controller routes using Route :: controller have been deprecated. Please use explicit route registration in your routes   filet. This will likely be extracted into a package.
  •   
  • The get, post, and other route helper functions have been removed. You may use the Route facade instead.
  •   
  • The database session driver from 5.1 has been renamed to legacy-database and will be removed. Consult notes on the "database   session driver "above for more information.
  •   
  • The Str :: randomBytes function has been deprecated in favor of the random_bytes native PHP function.
  •   
  • The Str :: equals function has been deprecated in favor of the hash_equals native PHP function.
  •   
  • Illuminate \ View \ Expression has been deprecated in favor of Illuminate \ Support \ HtmlString.
  •   
  • The WincacheStore cache driver has been removed.
  •   

In your code it would be:

public function create()
{

    $celula = new Celula();

    $tipos = TipoCelula::where('COD_IDENT_IGREJ', Auth::user()->COD_IDNET_IGREJ)
                         ->pluck('TXT_NOMEX_TIPOX','COD_TIPOX_CELUL');

    $igreja = Igreja::find(Auth::user()->COD_IDENT_IGREJ);

    return view('Celula.cadCelula', compact('celula', 'tipos', 'igreja'));

}

Reference:

29.09.2016 / 02:17