return response()->json(trans('errors.500'), 500);
$items = DB::table('table')
->whereYear('created_at', 2021)
->selectRaw('month(created_at) month, count(*) count')
->groupBy('month')
->get();
Потом мне нужно проверить приложение от лица гостя
public function booksWhereHasMyComments()
{
return $this->hasManyThrough(Book::class, Comment::class);
}
$user->booksWhereHasMyComments()
->with(['comments' => function ($query) use ($user) {
$query->where('user_id', $user->id);
}])
->get();