How to write such a query
SELECT COUNT(*) FROM (SELECT * FROM `drivers` where user_id = 1 order by trawel_date desc LIMIT 10) as tmp where (way1 = 25 or way2 = 25 or way3 = 25 ) using query builder Laravel 5? I can not figure out how to replace the FROM. The construction of the query starts with $this->drivers and this is equivalent to SELECT * FROM drivers . Tried through DB::raw transfer internal SELECT - does not work. And tried so
$tmp = $this->drivers->latest('trawel_date') ->where('user_id', '=', 1)->take(10)->get(); return $tmp->where('way1','=',25) ->orwhere('n2','=',25) ->orwhere('n3','=',25)->count(); the error is obtained. Is it possible to construct such a query? I really do not want to leave a request in this form. It would be nice, in a laravel way :)
Illuminate\Database\Eloquent\Collection::orwhere()is because the collection is returned. - Konstantin