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();
$this->renderable(function (NotFoundHttpException $e, $request) {
if ($request->is('users/*')) {
return response()->json([
'message' => 'Юзер не найден'
], 404);
}
});
User::where(function ($query) {
$query->where('name', 'John')
->orWhere('name', 'Vasja');
})
->where('last_name', '!=', 'Doe')
->get();