You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LiveCurrency.php 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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\Pages\Page;
  7. use Illuminate\Contracts\Support\Htmlable;
  8. use Livewire\Attributes\Url;
  9. class LiveCurrency extends Page
  10. {
  11. protected static ?string $navigationIcon = 'icon-currency-exchange';
  12. protected static ?string $title = 'Live Currency';
  13. protected static ?string $navigationGroup = 'Services';
  14. protected static ?string $slug = 'services/live-currency';
  15. protected static string $view = 'filament.company.pages.service.live-currency';
  16. #[Url]
  17. public ?string $activeTab = null;
  18. public function getTitle(): string | Htmlable
  19. {
  20. return translate(static::$title);
  21. }
  22. public static function getNavigationLabel(): string
  23. {
  24. return translate(static::$title);
  25. }
  26. public static function shouldRegisterNavigation(): bool
  27. {
  28. return Forex::isEnabled();
  29. }
  30. public function mount(): void
  31. {
  32. $this->loadDefaultActiveTab();
  33. abort_unless(Forex::isEnabled(), 403);
  34. }
  35. protected function loadDefaultActiveTab(): void
  36. {
  37. if (filled($this->activeTab)) {
  38. return;
  39. }
  40. $this->activeTab = $this->getDefaultActiveTab();
  41. }
  42. public function getDefaultActiveTab(): string | int | null
  43. {
  44. return 'currency-list';
  45. }
  46. public function getViewData(): array
  47. {
  48. return [
  49. 'currencyListQuery' => CurrencyList::query()->count(),
  50. 'companyCurrenciesQuery' => Currency::query()->count(),
  51. ];
  52. }
  53. }