Ik ben een vrij grote query aan het maken met de query builder van laravel. Maar ik krijg helaas niks terug van de query, terwijl als ik deze in phpmyadmin uitvoer krijg ik wel waardes terug. Ik ben vast heel dom bezig, maar ik ben er nu al een tijdje mee aan het prutsen en ik hoopte dat iemand het hier ziet.
<?php
/*
|--------------------------------------------------------------------------
| fetch {objsoorten, state}
| @return objecten
|--------------------------------------------------------------------------
*/
public static function fetch($objsoorten, $state = 'active') {
$query = DB::table('objecten')
->select('objecten.obj_idx', 'objectsoorten.objsoort_id', 'objectsoorten.objsoort_naam', 'objectspecificaties.objspec_waarde', 'objecten.obj_actief', 'attributen.attr_naam', 'attributen.attr_regex')
->join('objectsoorten', 'objectsoorten.objsoort_id', '=', 'objecten.objsoort_id')
->join('objectsoort_attributen', 'objectsoort_attributen.objsoort_id', '=', 'objectsoorten.objsoort_id')
->join('attributen', 'attributen.attr_id', '=', 'objectsoort_attributen.attr_id')
->join('objectspecificaties', function($join) {
$join->on('objectspecificaties.attr_id', '=', 'attributen.attr_id')
->on('objectspecificaties.obj_id', '=', 'objecten.obj_id');
})
->whereIn('objecten.obj_id', function($query) use ($objsoorten, $state) {
$query->select('objecten.obj_id')
->from('objecten')
->join('objectsoorten', 'objectsoorten.objsoort_id', '=', 'objecten.objsoort_id')
->join('objectspecificaties', 'objectspecificaties.obj_id', '=', 'objecten.obj_id')
->where('objectspecificaties.objspec_waarde', 'LIKE', '\'%%\'');
if(is_array($objsoorten)) {
foreach($objsoorten as $key => $id) {
if($key == 0) {
$query->where('objecten.objsoort_id', '=', intval($id));
} else {
$query->orWhere('objecten.objsoort_id', '=', intval($id));
}
}
} else {
$query->where('objecten.objsoort_id', '=', $objsoorten);
}
if($state == 'all') {
$query->where('objecten.obj_actief', '=', 0);
$query->orWhere('objecten.obj_actief', '=', 1);
} elseif($state == 'active') {
$query->where('objecten.obj_actief', '=', 1);
} elseif($state == 'inactive') {
$query->where('objecten.obj_actief', '=', 0);
}
$query->groupBy('objecten.obj_id');
})
->groupBy('objectsoort_attributen.attr_id')
->groupBy('objecten.obj_id')
->orderBy('objectsoort_attributen.objsoort_id')
->orderBy('objecten.obj_id')
->orderBy('attributen.attr_id')
->get();
var_dump($query);
return ($query) ? $query : false;
}
?>
De var dump:
array(0) { }De resultset van phpmyadmin:

Alvast bedankt voor de gene die me kan helpen.