Q:

Why does not work SQL query Laravel?

I have the following SQL query:
return User::where("users.id", $id)
            ->select(array('rating.rate', User::raw('count(offers.id) AS ofrs, count(announcements.id) as appts')))
            ->join('announcements', 'users.id', '=', 'announcements.user_id')
            ->join('offers', 'users.id', '=', 'offers.user_id')
            ->join('rating', 'users.id', '=', 'rating.user_id')
            ->group_by('ofrs')
            ->get();

It gives me an error:

BadMethodCallException in Builder.php line 2508: Call to undefined
  method Illuminate\Database\Query\Builder::group_by()

Why does not work group by?
Also as way I tried:
  return User::where("users.id", $id)
            ->selectRaw('rating.rate, count(offers.id) AS ofrs, count(announcements.id) as appts')
            ->groupBy('appts')
            ->groupBy('ofrs')
            ->join('announcements', 'users.id', '=', 'announcements.user_id')
            ->join('offers', 'users.id', '=', 'offers.user_id')
            ->join('rating', 'users.id', '=', 'rating.user_id')
            ->get();

Result:
SQLSTATE[42000]: Syntax error or access violation: 1056 Can't group on 'appts'

I have written SQL query directly in SQL:
select rating.rate, COUNT(offers.id) AS ofrs, COUNT(announcements.id) as appts from `users` left join `announcements` on `users`.`id` = `announcements`.`user_id` left join `offers` on `users`.`id` = `offers`.`user_id` left join `rating` on `users`.`id` = `rating`.`user_id` where `users`.`id` = 1

It works, by model is not:
return User::where("users.id", $id)
            ->selectRaw('rating.rate, COUNT(offers.id) AS ofrs, COUNT(announcements.id) as appts')
            ->leftJoin('announcements', 'users.id', '=', 'announcements.user_id')
            ->leftJoin('offers', 'users.id', '=', 'offers.user_id')
            ->leftJoin('rating', 'users.id', '=', 'rating.user_id')
            ->get();

This work:
return User::where("users.id", $id)
            ->selectRaw('rating.rate, COUNT(offers.id) AS ofrs, COUNT(announcements.id) AS appts')
            ->leftJoin('announcements', 'users.id', '=', 'announcements.user_id')
            ->leftJoin('offers', 'users.id', '=', 'offers.user_id')
            ->leftJoin('rating', 'users.id', '=', 'rating.user_id')
            ->groupBy('rating.rate')
            ->get();

A:

You need to read on how SQL works. You can't group by counted alias. What you are looking for is probably three queries or three relations. 
You should create relation on User for announcements, second one for offers and third for ratings.
Than you would User::find($id)->announcements->count(), User::find($id)->offers->count() and User::find($id)->ratings->count()
Or you can use your Fluent way with something like:
return User::find($id)
            ->leftJoin('announcements', 'users.id', '=', 'announcements.user_id')
            ->count();

