$this->id, 'rating' => $this->rating, 'comment' => $this->comment, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'user' => $this->whenLoaded('user', function (): ?array { if (! $this->user) { return null; } return [ 'id' => $this->user->id, 'name' => $this->user->name, 'avatarUrl' => $this->user->avatar_url ? asset(Storage::url($this->user->avatar_url)) : null, ]; }), ]; } }