I have made this query:
$query = UserHistoryAccess::with('user') ->select('user_history_accesses.*', DB::raw('count(user_history_accesses.id) as total')) ->join('users', 'user_history_accesses.user_id', 'users.id') ->groupBy('user_history_accesses.user_id') ->where('total', 'like', '%' . $term . '%') ; Even I have followed this solution but I got this error :
Illuminate\Database\QueryException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'total' in 'where clause' (SQL: select count(*) as aggregate from
user_history_accessesinner joinusersonuser_history_accesses.user_id=users.idwheretotallike %388%) in file C:\xampp\htdocs\HabilitisBack\vendor\laravel\framework\src\Illuminate\Database\Connection.php on line 671
totalcolumn here?count(user_history_accesses.id)not column