Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call to undefined method "Builder::getAfterFilters" while upgrading to Laravel 4

Tags:

laravel-4

I try to upgrade from Laravel 3 to 4 but i get this error everywhere

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

Someone know where this can come ?

enter image description here

like image 841
Tahola Avatar asked Mar 26 '14 16:03

Tahola


1 Answers

I had this error too so I'll just post my observations here. It can always help someone !

It appears that getAfterFilters() is a method that is required for all controllers in L4. If the error says it's not defined, you probably forgot to extend BaseController in your class.

Knowing that, the obvious fix would be to extend BaseController... but you don't nececarly have to if it's not needed. In my case, my class had to be a valid controller because of a very stupid reason. I was using the following route syntax :

Route::get('sse', 'SSE@deamon');

SSE was not extending BaseController (didn't need to imho) But this route syntax requires you to use a controller class that extends BaseController... so I changed it for:

Route::get('sse', [function() {
    SSE::deamon();
}]);

and it now works without the missing getAfterFilters() error !

like image 198
Arnaud Massé Avatar answered Oct 05 '22 04:10

Arnaud Massé