-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
You cannot user Where
filter with a different name vs column.
#6
Comments
We could do something very ugly in the /** @var \Illuminate\Database\Eloquent\Builder $builder */
$builder = $this->route->schema()::model()::query();
$query = $builder->getQuery();
$probableColumn = $builder->qualifyColumn($key);
$this->filter->apply($builder, 'appliedWhere');
foreach($builder->getQuery()->wheres as $where) {
if ($where['value'] === 'appliedWhere' && $where['column'] !== $probableColumn) {
$column = $where['column'];
}
} But perhaps its just better to make sure there is no empty ecamples: $examples = collect($this->generator->resources()
->resources($this->route->schema()::model()))
->pluck($column)
->filter()
->map(function ($f) {
// @todo Watch out for ids?
return Example::create($f)->value($f);
})
->toArray(); This also applies to other filters with the following signature |
The related pull request (laravel-json-api/eloquent#18) has been merged, the methods are now public and part of the trait "Conceirns\HasColum". This means we can sniff this out and ask for the column name, fixing this bug :) |
Very nice, gonna implement it in the next days! |
When configuring a filter as follows:
The generator breaks, it tries to get example data from the name of the filter, ignoring the column.
The text was updated successfully, but these errors were encountered: