Skip to content

Commit

Permalink
Merge pull request #11 from abdosaeedelhassan/main
Browse files Browse the repository at this point in the history
Display number of notification
  • Loading branch information
199ocero authored Oct 4, 2024
2 parents 374b32e + ee35757 commit c6e30a0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 17 deletions.
9 changes: 9 additions & 0 deletions config/filachat.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,15 @@
*/
'navigation_label' => 'FilaChat',

/*
|--------------------------------------------------------------------------
| Navigation Badge
|--------------------------------------------------------------------------
|
| This option specifies the user number of unread message badge in the sidebar.
*/
'navigation_display_unread_messages_count' => false,

/*
|--------------------------------------------------------------------------
| Navigation Icon
Expand Down
50 changes: 33 additions & 17 deletions src/Pages/FilaChat.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,37 @@ class FilaChat extends Page

public $selectedConversation;

public static function getSlug(): string
{
return config('filachat.slug') . '/{id?}';
}

public static function getNavigationLabel(): string
{
return __(config('filachat.navigation_label'));
}

public static function getNavigationBadgeColor(): string|array|null
{
$count = intval(self::getNavigationBadge());
return $count > 0 ? 'danger' : parent::getNavigationBadgeColor();
}

public static function getNavigationBadge(): ?string
{
if (config('filachat.navigation_display_unread_messages_count')) {
return FilaChatMessage::query()
->where('last_read_at', null)
->where('receiverable_id', auth()->id())->count();
}
return parent::getNavigationBadge();
}

public static function getNavigationIcon(): string|Htmlable|null
{
return config('filachat.navigation_icon');
}

public function mount(?int $id = null): void
{
if ($id) {
Expand All @@ -34,32 +65,17 @@ public function mount(?int $id = null): void
}
}

public static function getSlug(): string
{
return config('filachat.slug') . '/{id?}';
}

public function getTitle(): string
{
return __(config('filachat.navigation_label'));
}

public static function getNavigationLabel(): string
{
return __(config('filachat.navigation_label'));
}

public static function getNavigationIcon(): string | Htmlable | null
{
return config('filachat.navigation_icon');
}

public function getMaxContentWidth(): MaxWidth | string | null
public function getMaxContentWidth(): MaxWidth|string|null
{
return config('filachat.max_content_width');
}

public function getHeading(): string | Htmlable
public function getHeading(): string|Htmlable
{
return ''; // should be empty by default
}
Expand Down

0 comments on commit c6e30a0

Please sign in to comment.