Call to Undefined method Illuminate Database Query Builder::lists()

Asked

Viewed 994 times

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?

1 answer

3


The method lists is obsoleta (deprecated) and was replaced by pluck according to Upgrading To 5.2.0 From 5.1, and in the version 5.3 was removed. In fact there was only one change in the name the rest is the same as 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 has 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 file. 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:

  • As would be my case in the new version ?

  • I made the edition @Renanrodrigues with the code! only really changed the name of the method.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.