I have a Model ImageRequest that is related to my User model like this:
public function user()
{
return $this->belongsTo('App\User');
}
An my User model like this:
public function imageRequests()
{
return $this->hasMany('App\ImageRequest');
}
Now I use this package to build my filterable query to fetch all ImageRequests:
this is what my query looks like:
$query = QueryBuilder::for(ImageRequest::class)
->with(['requestTypes'])
->allowedIncludes('requestTypes')
->orderByRaw("FIELD(status , 'new') desc")
->orderBy('functional_id', 'asc')
->allowedFilters(
'id',
'pv_number',
'created_at',
Filter::scope('starts_between'),
'location_of_facts',
'train_nr',
'status',
'result_of_search',
Filter::custom('type', RequestTypeFilter::class)
);
I need to add a where clause for the User model something like this:
->where('zone', Auth::user->zone);
But it says:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'zone' in 'where clause' (SQL: select count(*) as aggregate from
image_requests
wherezone
= a)
from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2DHYXjs
via IFTTT
Aucun commentaire:
Enregistrer un commentaire