Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

LiveCurrency.php 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace App\Filament\Company\Pages\Service;
  3. use App\Facades\Forex;
  4. use App\Models\Service\CurrencyList;
  5. use App\Models\Setting\Currency;
  6. use Filament\Facades\Filament;
  7. use Filament\Pages\Page;
  8. use Illuminate\Contracts\Support\Htmlable;
  9. use Livewire\Attributes\Url;
  10. class LiveCurrency extends Page
  11. {
  12. protected static ?string $title = 'Live Currency';
  13. protected static ?string $slug = 'services/live-currency';
  14. protected static string $view = 'filament.company.pages.service.live-currency';
  15. #[Url]
  16. public ?string $activeTab = null;
  17. public function getTitle(): string | Htmlable
  18. {
  19. return translate(static::$title);
  20. }
  21. public static function getNavigationLabel(): string
  22. {
  23. return translate(static::$title);
  24. }
  25. public static function getNavigationParentItem(): ?string
  26. {
  27. if (Filament::hasTopNavigation()) {
  28. return translate('Banking');
  29. }
  30. return null;
  31. }
  32. public static function shouldRegisterNavigation(): bool
  33. {
  34. return Forex::isEnabled();
  35. }
  36. public function mount(): void
  37. {
  38. $this->loadDefaultActiveTab();
  39. abort_unless(Forex::isEnabled(), 403);
  40. }
  41. protected function loadDefaultActiveTab(): void
  42. {
  43. if (filled($this->activeTab)) {
  44. return;
  45. }
  46. $this->activeTab = $this->getDefaultActiveTab();
  47. }
  48. public function getDefaultActiveTab(): string | int | null
  49. {
  50. return 'currency-list';
  51. }
  52. public function getViewData(): array
  53. {
  54. return [
  55. 'currencyListQuery' => CurrencyList::query()->count(),
  56. 'companyCurrenciesQuery' => Currency::query()->count(),
  57. ];
  58. }
  59. }