bugfix in Container.php: also return empty containers again

This commit is contained in:
j3d1 2020-01-17 20:03:24 +01:00
parent 1ee019a37f
commit dbc4a84d3f

View file

@ -29,14 +29,14 @@ class Container extends Model
protected $hidden = ['created_at', 'deleted_at', 'updated_at'];
static function all($columns=Array()){
return Container::join('items','items.cid','=','containers.cid')
->select('items.cid', 'name', DB::raw('count(*) as itemCount'))
->groupBy('items.cid', 'name')->get();
return Container::leftJoin('items','items.cid','=','containers.cid')
->select('containers.cid', 'name', DB::raw('count(items.iid) as itemCount'))
->groupBy('containers.cid', 'name')->get();
}
static function find($id){
return Container::join('items','items.cid','=','containers.cid')
->select('items.cid', 'name', DB::raw('count(*) as itemCount'))
->groupBy('items.cid', 'name')->where('items.cid', '=', $id)->first();
return Container::leftJoin('items','items.cid','=','containers.cid')
->select('containers.cid', 'name', DB::raw('count(items.iid) as itemCount'))
->groupBy('containers.cid', 'name')->where('items.cid', '=', $id)->first();
}
}