php - Laravel SQLite whereHas queries not working -
i'm using sqlite laravel app , trying run wherehas
query:
$payments = payment::wherehas('payers', function($q){ $q->where('user_id', '=', 1); })->get();
this returns empty result , due integer 1 being cast string evidenced resulting query generated laravel/eloquent:
select * "payments" (select count(*) "payers" inner join "payer_payment" on "payers"."id" = "payer_payment"."payer_id" "payer_payment"."payment_id" = "payments"."id" , "user_id" = 1) >= '1'
having reviewed this github issue tried using db::raw
so:
$payments = payment::wherehas('payers', function($q){ $q->where('user_id', '=', db::raw(1)); })->get();
but no improvement. how can fix without changing database driver?
$payments = payment::wherehas('payers', function($q){ $q->where('user_id', '=', 1); }, '>=', db::raw(1))->get();
Comments
Post a Comment