I am using laravel 7.7.1 and in a query I pass a variable iaw the docs like so:
public function show($graad=3)
{
$sums=Sum::where(function ($query) use($graad) {
$query->where('graad',$graad);
})->inRandomOrder()->limit(1)->toSql();
Result is always:
"select * from `sums` where (`graad` = ?) order by RAND() limit 1"
So the variable is not passed in the correct way and converted to a "?".
Changing the value of $graad='test' or $graad='3' or even typehinting with
public function show(int $graad=3)
does result in
"select * from `sums` where (`graad` = ?) order by RAND() limit 1"
The column graad in the table is an int(11). What am I doing wrong?