Is there a way to apply certain conditions to the list of records displayed by Voyager's BREAD? For example, only display records where a certain column is blank (ie WHERE 'col_name' IS NULL
)?
UPDATE (17/12/18):
You can override the controller and add the where clause. For example, if you need to override "Posts" list, then you should:
php artisan make:controller PostController
class PostController extends \\TCG\\Voyager\\Http\\Controllers\\VoyagerBaseController
use TCG\\Voyager\\Facades\\Voyager;
\\vendor\\tcg\\Voyager\\Http\\Controllers\\VoyagerBaseController
$dataType = Voyager::model('DataType') ->where('slug', '=', $slug) ->where('col_name', '=', NULL) ->first();
You can also set $orderBy = 'col_name'
and $sortOrder = 'asc'/'desc'
custom values in the same function. Here Voyager's docs.
OLD:
Yes, there is. You need to edit the view and apply a condition filter. Here is explained how to override views (and controllers if you want to filter it before sending the data to the view).
Just define a Scope in your model:
public function scopeMyScope($query)
{
return $query->where('col_name', null);
}
then go to Bread Form and select it form Scope drop down :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.