I don't know about toSql() but if you want to get the query created then you might want to look at the logs of the queries executed for that request.
$queries = DB::getQueryLog();
dd($queries);
Or get the last query executed:
$queries = DB::getQueryLog();
$last_query = end($queries);
Or maybe (warning untested code)
public function scopeiOS( Illuminate\Database\Query\Builder $query ){
$result = $query->select( DB::raw('count(`platform`) as iOS' ) )
->where( 'platform' , '=', 'iOS' )
->pluck('iOS');
}
Check this for more information on toSql().
/**
* Get the SQL representation of the query.
*
* @return string
*/
public function toSql()
{
return $this->grammar->compileSelect($this);
}
toSql()is a method attributed to QueryBuilder object only.... none the less, with this rude attitude, good luck getting an answer from others too.toSql().