fix: eager loading of user for echo and audible eloquent resources

This commit is contained in:
Roardom
2025-08-22 02:20:30 +00:00
parent 67058a702c
commit f3bb05a93b
3 changed files with 7 additions and 7 deletions
+2 -2
View File
@@ -304,7 +304,7 @@ class NerdBot
$echoes = cache()->remember(
'user-echoes'.$target->id,
3600,
fn () => UserEcho::with(['room', 'target', 'bot'])->where('user_id', '=', $target->id)->get()
fn () => UserEcho::with(['user', 'room', 'target', 'bot'])->where('user_id', '=', $target->id)->get()
);
if ($echoes->doesntContain(fn ($echo) => $echo->bot_id == $this->bot->id)) {
@@ -322,7 +322,7 @@ class NerdBot
$audibles = cache()->remember(
'user-audibles'.$target->id,
3600,
fn () => UserAudible::with(['room', 'target', 'bot'])->where('user_id', '=', $target->id)->get()
fn () => UserAudible::with(['user', 'room', 'target', 'bot'])->where('user_id', '=', $target->id)->get()
);
if ($audibles->doesntContain(fn ($audible) => $audible->bot_id == $this->bot->id)) {
+2 -2
View File
@@ -181,7 +181,7 @@ class SystemBot
$echoes = cache()->remember(
'user-echoes'.$target->id,
3600,
fn () => UserEcho::with(['room', 'target', 'bot'])->where('user_id', '=', $target->id)->get()
fn () => UserEcho::with(['user', 'room', 'target', 'bot'])->where('user_id', '=', $target->id)->get()
);
if ($echoes->doesntContain(fn ($echo) => $echo->bot_id == $this->bot->id)) {
@@ -199,7 +199,7 @@ class SystemBot
$audibles = cache()->remember(
'user-audibles'.$target->id,
3600,
fn () => UserAudible::with(['room', 'target', 'bot'])->where('user_id', '=', $target->id)->get()
fn () => UserAudible::with(['user', 'room', 'target', 'bot'])->where('user_id', '=', $target->id)->get()
);
if ($audibles->doesntContain(fn ($audible) => $audible->bot_id == $this->bot->id)) {
+3 -3
View File
@@ -196,7 +196,7 @@ class ChatController extends Controller
$echoes = cache()->remember(
'user-echoes'.$user1Id,
3600,
fn () => UserEcho::with(['room', 'target', 'bot'])->where('user_id', '=', $user1Id)->get()
fn () => UserEcho::with(['user', 'room', 'target', 'bot'])->where('user_id', '=', $user1Id)->get()
);
if ($echoes->doesntContain(fn ($echo) => $echo->target_id == $user2Id)) {
@@ -216,7 +216,7 @@ class ChatController extends Controller
$audibles = cache()->remember(
'user-audibles'.$user1Id,
3600,
fn () => UserAudible::with(['room', 'target', 'bot'])->where('user_id', '=', $user1Id)->get()
fn () => UserAudible::with(['user', 'room', 'target', 'bot'])->where('user_id', '=', $user1Id)->get()
);
if ($audibles->doesntContain(fn ($audible) => $audible->target_id == $user2Id)) {
@@ -403,7 +403,7 @@ class ChatController extends Controller
$echoes = cache()->remember(
'user-echoes'.$user->id,
3600,
fn () => UserEcho::with(['room', 'target', 'bot'])->where('user_id', '=', $user->id)->get(),
fn () => UserEcho::with(['user', 'room', 'target', 'bot'])->where('user_id', '=', $user->id)->get(),
);
if ($echoes->doesntContain(fn ($echo) => $echo->room_id == $room->id)) {