Hey,
I use something like this which works fine.
$data = Server::count(['group' => 'modpack_id']);
foreach ($data as $key => $value) {
echo "There are ", $value->rowcount, " in ", $value->modpack_id;
}
But now I want the modpack name from the foreign key table. I set the hasMany and belongsTo like always and it works fine with a normal select querie. But in this case I have no idea on how to manage it. Calling one extra query per modpack wouldn't be a good choice.
If something like this would work it would be great, is there a way to get it working, or how would you manage it?
$data = Server::count(['group' => 'modpack_id']);
foreach ($data as $key => $value) {
echo "There are ", $value->rowcount, " in ", $value->modpack->name;
}