This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
When I investigated soure code of the RelationController, I found this method
/**
* !!!!
* !!!! WARNING: DO NOT USE - This method is scheduled to be removed
* !!!!
*
* Controller override: Extend the query used for populating the list
* after the default query is processed.
* @param October\Rain\Database\Builder $query
* @param string $field
*/
public function relationExtendQuery($query, $field)
{
}
If this method is removed, how can I replace it??? I need this method or its likeness
+1
How else would one achieve the documented functionality?
Extend the query used for populating the list after the default query is processed.
+1 this would solve my issues with scope & conditions not working while setting relationships on custom models
+1 again, This is the only way we found to filter results displayed in a relationship manager for now.
Wil there be a replacement solution for that when it'll be deleted ?
It seems that you can use events to get your way around :
Event::listen('backend.list.extendQuery', function ($widget, $query) {
// Test your model
if ($widget->model instanceof \You\Plugin\Models\YourModel) {
// Add conditions to the $query
}
}
I think the docs needs more information on the available events and what we can do with it.
Last updated
Ok. And tell me, pls, how can I use related field for extend query?! Like here:
public function relationExtendQuery($query, $field)
{
if ($field == 'same_field') {
$query->...
}
}
https://github.com/octobercms/october/issues/1780#issuecomment-186411450
Look at the
relationExtendViewWidget
andrelationExtendManageWidget
methods. These are the replacement overrides.public function relationExtendViewWidget($widget, $field) { $widget->bindEvent('list.extendQuery', function() { ... }); }
https://github.com/octobercms/october/issues/1780#issuecomment-186411450
Look at the
relationExtendViewWidget
andrelationExtendManageWidget
methods. These are the replacement overrides.public function relationExtendViewWidget($widget, $field) { $widget->bindEvent('list.extendQuery', function() { ... }); }
voidshah said:
Ok. And tell me, pls, how can I use related field for extend query?! Like here:
public function relationExtendQuery($query, $field) { if ($field == 'same_field') { $query->... } }
1-11 of 11