Hello,
I'm new with eloquent, working as it, standalone :) it works pretty good with simple query, but I'm unable to make just a count(*) with groupBy... Here is the code:
class Btc extends Illuminate\Database\Eloquent\Model {
static function getNb(int $mid, array $btc = [], array $etat = []) {
$req = Btc::select('btc_mid', 'btc_type', Btc::raw('COUNT(*) as btc_nb'))->where('btc_mid', '=', $mid);
if(!empty($btc))
$req->whereIn('btc_id', $btc);
if(!empty($etat))
$req->whereIn('btc_etat', $etat);
echo $req->toSql();
// indexer le resultat sur btc_type
return index_array($req->groupBy('btc_mid', 'btc_type')->get(), 'btc_type');
}
}
and the error:
Warning : strtolower() expects parameter 1 to be string, object given
URL: /gen.html
File: Grammar[058]
the 'toSql' I added show me the trouble: the request is not complete, missing the predicate count(*) but I can't undersand where i'm wrong?
select btc_mid, btc_type, from zrd_btc where btc_mid = ? and btc_etat in (?)