-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
304 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
namespace Coyote\Domain\User; | ||
|
||
class MenuItem | ||
{ | ||
/** @var (string|int)[] */ | ||
public array $route; | ||
public ?string $htmlIcon = null; | ||
|
||
public function __construct( | ||
public string $title, | ||
public string $routeName, | ||
array $routeArguments = [], | ||
public ?string $htmlId = null, | ||
public ?string $htmlClass = null, | ||
string $htmlIcon = null | ||
) | ||
{ | ||
if ($htmlIcon) { | ||
$fixedWidth = 'fa-fw'; | ||
$this->htmlIcon = "fa $fixedWidth $htmlIcon"; | ||
} | ||
$this->route = [$routeName, ...$routeArguments]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
namespace Coyote\Domain\User; | ||
|
||
class User | ||
{ | ||
public function __construct( | ||
public bool $loggedIn, | ||
public ?int $id | ||
) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
<?php | ||
namespace Coyote\Domain\User; | ||
|
||
class UserMenu | ||
{ | ||
/** | ||
* @return MenuItem[] | ||
*/ | ||
public function profileNavigation(User $user): array | ||
{ | ||
if ($user->loggedIn) { | ||
return [ | ||
new MenuItem('Moje konto', 'user.home'), | ||
new MenuItem('Ustawienia', 'user.settings'), | ||
new MenuItem('Profil', 'profile', routeArguments: [$user->id]), | ||
]; | ||
} | ||
return []; | ||
} | ||
|
||
/** | ||
* @return MenuItem[] | ||
*/ | ||
public function favouriteTabs(): array | ||
{ | ||
return [ | ||
new MenuItem('Wątki na forum', 'user.favorites.forum'), | ||
new MenuItem('Oferty pracy', 'user.favorites.job'), | ||
new MenuItem('Mikroblogi', 'user.favorites.microblog'), | ||
]; | ||
} | ||
|
||
/** | ||
* @return MenuItem[] | ||
*/ | ||
public function settingsMenu(): array | ||
{ | ||
return [ | ||
new MenuItem('Podstawowa konfiguracja', | ||
'user.settings', | ||
htmlId: 'btn-start', | ||
htmlIcon: 'fa-cog'), | ||
new MenuItem('Umiejętności', | ||
'user.skills', | ||
htmlId: 'btn-visits', | ||
htmlIcon: 'fa-wrench'), | ||
new MenuItem('Bezpieczeństwo', | ||
'user.security', | ||
htmlId: 'btn-notifies', | ||
htmlIcon: 'fa-lock'), | ||
new MenuItem('Zmiana hasła', | ||
'user.password', | ||
htmlId: 'btn-pm', | ||
htmlIcon: 'fa-key'), | ||
new MenuItem('Ustawienia powiadomień', | ||
'user.notifications.settings', | ||
htmlId: 'btn-favorites', | ||
htmlIcon: 'fa-bell'), | ||
new MenuItem('Zablokowani oraz obserwowani', | ||
'user.relations', | ||
htmlId: 'btn-favorites', | ||
htmlIcon: 'fa-user-slash'), | ||
new MenuItem('Tokeny API', | ||
'user.tokens', | ||
htmlId: 'btn-favorites', | ||
htmlIcon: 'fa-key') | ||
]; | ||
} | ||
|
||
/** | ||
* @return MenuItem[] | ||
*/ | ||
public function accountMenu(): array | ||
{ | ||
return [ | ||
new MenuItem( | ||
'Start', | ||
'user.home', | ||
htmlId: 'btn-start', | ||
htmlIcon: 'fa-map-marker' | ||
), | ||
new MenuItem( | ||
'Powiadomienia', | ||
'user.notifications', | ||
htmlId: 'btn-notifies', | ||
htmlIcon: 'fa-bell'), | ||
new MenuItem( | ||
'Wiadomości prywatne', | ||
'user.pm', | ||
htmlId: 'btn-pm', | ||
htmlIcon: 'fa-envelope'), | ||
new MenuItem( | ||
'Ulubione i obserwowane strony', | ||
'user.favorites', | ||
htmlId: 'btn-favorites', | ||
htmlIcon: 'fa-heart'), | ||
new MenuItem( | ||
'Oceny moich postów', | ||
'user.rates', | ||
htmlId: 'btn-rates', | ||
htmlIcon: 'fa-star-half'), | ||
new MenuItem( | ||
'Statystyki moich postów', | ||
'user.stats', | ||
htmlId: 'btn-stats', | ||
htmlIcon: 'fa-chart-bar'), | ||
new MenuItem( | ||
'Zaakceptowane odpowiedzi', | ||
'user.accepts', | ||
htmlId: 'btn-accepts', | ||
htmlIcon: 'fa-check'), | ||
new MenuItem( | ||
'Usuń konto', | ||
'user.delete', | ||
htmlClass: 'text-danger', | ||
htmlIcon: 'fa-trash-alt') | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Coyote\Http\Controllers\User\Menu; | ||
|
||
use Coyote\Domain\User\UserMenu; | ||
use Lavary\Menu\Builder; | ||
use Lavary\Menu\Menu; | ||
|
||
trait AccountMenu | ||
{ | ||
public function getSideMenu(): Builder | ||
{ | ||
$menuItems = (new UserMenu())->accountMenu(); | ||
|
||
/** @var Menu $menu */ | ||
$menu = app(Menu::class); | ||
|
||
return $menu->make('user.home', function (Builder $menu) use ($menuItems) { | ||
foreach ($menuItems as $menuItem) { | ||
$menu | ||
->add($menuItem->title, [ | ||
'id' => $menuItem->htmlId ?? '', | ||
'class' => $menuItem->htmlClass ?? '', | ||
'route' => $menuItem->route | ||
]) | ||
->prepend("<i class=\"$menuItem->htmlIcon\"></i>"); | ||
} | ||
|
||
$user = auth()->user(); | ||
$menu | ||
->find('btn-pm') | ||
->append(' <small>(' . $user->pm_unread . '/' . $user->pm . ')</small>'); | ||
}); | ||
} | ||
} |
Oops, something went wrong.