Closed k98kurz closed 4 years ago
Question: What are you trying to achieve with the getQuery
then has
?
@Mulkave the idea is to build a robust, queryable API endpoint. Example:
$offset = request('offset', 0);
$limit = request('limit', 50);
$sortBy = request('sortBy', $this->defaultSortTag);
$sortDirection = request('sortDirection', 'asc');
$equalFields = request('equal', []);
$notEqualFields = request('notequal', []);
$greatedThenFields = request('greater', []);
$lessThenFields = request('less', []);
$likeFields = request('like', []);
$with = request('relations', []);
$has = request('has', []);
$orhas = request('orhas', []);
$query = $this->getListQuery();
// parse search terms
foreach($equalFields as $key => $value){
$query = $query->where($key, $value);
}
foreach($notEqualFields as $key => $value){
$query = $query->where($key, '!=', $value);
}
foreach($greatedThenFields as $key => $value){
$query = $query->where($key, '>', is_numeric($value) ? intval($value) : $value);
}
foreach($lessThenFields as $key => $value){
$query = $query->where($key, '<', is_numeric($value) ? intval($value) : $value);
}
foreach($likeFields as $key => $value){
$query = $query->where($key, '=~', ".*$value.*");
}
foreach ($has as $key => $value) {
$query = $query->has($value);
}
foreach ($orhas as $key => $value) {
$query = $query->orHas($value);
}
$total = $query->count();
$limit = $limit > 200 ? 200 : $limit;
$limit = (count($has) || count($orhas) || count($with)) ? 100 : $limit;
$results = $this->getOrderBy($query, $sortBy, $sortDirection)->offset($offset)->take($limit)->with($with)->get();
This is pretty old. Not sure if this is still valid or whether you were able to work it out?
If not, can you please try skipping the getQuery()
call and see if any error occurs then?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Introduction
I am trying to apply user-supplied search parameters to models of a hasMany relation. One of the features I wanted to have was checking of relations on the related models via the
has
andorHas
Eloquent methods. My understanding is that callinggetQuery
on a relation returns anEloquent\Builder
, which should be able to handlehas
andorHas
method calls.Example Code
ParentModel.php
Thing.php
Http/Controllers/ParentThingController.php
Error Message
This error is a Neo.ClientError.Statement.SyntaxError generated by Neo4j. I have been working with Neo4j for only a couple of months and am not sure how to fix the query generation to avoid this.