I have next SQL query:
SELECT summary_table.device_id, WEEKDAY(summary_table.day) as day, AVG(summary_table.shows) as avg_shows FROM ( SELECT device
Take a look at the docs here, scroll down to "Using Where In With An Array":
http://four.laravel.com/docs/queries
The whereIn method takes an array, so pass in $var directly, no need to implode.
whereIn
$var
->whereIn('device_id', $var)