php - Error when using selectRaw() Laravel method with parameter binding

Solution:

I tried other ways for hours, until I ask in a community and someone answered me that it's not possible to do this. The binding will only works with column values or something like that, despite that it doesn't have detailed uses of the selectRaw method.

Well, I've lost many hours, so I gave up and went to my objective with another approach.

Answer

Solution:

You can use param in selectRaw by using quotes

Example:

$column = 1;
$query->selectRaw('count(**$column**)');

Source