Crud: filters error

Created on 29 Nov 2016  路  5Comments  路  Source: Laravel-Backpack/CRUD

here is my filter

$this->crud->addFilter(['name' => 'active',
            'label' => "Subscribed",
            'type' => 'simple']);

I got

FatalThrowableError in Filters.php line 133: Call to a member function url() on null
 "laravel/framework": "5.3.*",
    "backpack/base": "^0.7.6",
    "backpack/permissionmanager": "^2.1",
    "backpack/crud": "^3.1",

Most helpful comment

@OwenMelbz Thanks for your reply. The removing of __construct and replacing with setup() method works for me

All 5 comments

Same problem in my project as i wanted to add a filter:

$this->crud->addFilter([ // add a "simple" filter called Active
            'type' => 'simple',
            'name' => 'active',
            'label'=> 'Active'
        ],
            false,
            function() {
                $this->crud->addClause('where', 'active', '1');
            });

@iboargun and @iboargun

at the top of your crud controller, do you have public function __construct() or public function setup() ?

Or maybe you have got a custom __construct?

The issue is, when the library loads, within its __construct it does $this->request = $request;

However if you're using a custom construct, it might not be calling this function, which is why it breaks further down the line.

If you are using __construct please rename it to setup and remove any parent::__construct()

Thanks

I apologize for my late reply, but even if you keep the constructor and initialize the parent, you have to override the parent's
public function setup() {}
as per the documentation all filters' setup should be in the EntityCrudController::setup()

@RamiMustaklem What I'm saying is, remove your existing __construct this is what is most likely causing the issue.

If you make sure you ONLY use a setup function see if your filter works as expected

@OwenMelbz Thanks for your reply. The removing of __construct and replacing with setup() method works for me

Was this page helpful?
0 / 5 - 0 ratings