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.5KB

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