Skip to content

Commit

Permalink
Only add the username property if it's not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
RVxLab authored and freekmurze committed Jul 15, 2024
1 parent 932c05e commit 9f116d4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Notifications/Channels/Discord/DiscordMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ public function fields(array $fields, bool $inline = true): self

public function toArray(): array
{
return [
'username' => $this->username ?? 'Laravel Backup',
$data = [
'avatar_url' => $this->avatarUrl,
'embeds' => [
[
Expand All @@ -132,5 +131,11 @@ public function toArray(): array
],
],
];

if (!empty($this->username)) {
$data['username'] = $this->username;
}

return $data;
}
}

0 comments on commit 9f116d4

Please sign in to comment.