Extending list query look up from outside controller

- 1 answer

Ad

The docs shows how to extend the look up query for a backend list from inside a controller using listExtendQuery
Can it be extended from outside the controller i.e from another plugin?

Ad

Answer

Ad

Use Event in boot() function of your plugin

Event::listen('backend.list.extendQuery', function ($widget, $query) {
    // Check your model
    if ($widget->model instanceof \You\Plugin\Models\YourModel) {
        // extend $query
    }
}
Ad
source: stackoverflow.com
Ad