Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

ConfigureCompanyDefault.php 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace App\Listeners;
  3. use App\Events\CompanyConfigured;
  4. use App\Services\CompanySettingsService;
  5. use App\Utilities\Currency\ConfigureCurrencies;
  6. use Filament\Facades\Filament;
  7. use Filament\Forms\Components\DatePicker;
  8. use Filament\Forms\Components\Section;
  9. use Filament\Forms\Components\Tabs\Tab;
  10. use Filament\Resources\Components\Tab as ResourcesTab;
  11. class ConfigureCompanyDefault
  12. {
  13. /**
  14. * Handle the event.
  15. */
  16. public function handle(CompanyConfigured $event): void
  17. {
  18. $company = $event->company;
  19. $companyId = $company->id;
  20. session(['current_company_id' => $companyId]);
  21. $settings = CompanySettingsService::getSettings($companyId);
  22. app()->setLocale($settings['default_language']);
  23. locale_set_default($settings['default_language']);
  24. Filament::getPanel('company')
  25. ->brandName($company->name);
  26. DatePicker::configureUsing(static function (DatePicker $component) use ($settings) {
  27. $component
  28. ->displayFormat($settings['default_date_format'])
  29. ->firstDayOfWeek($settings['default_week_start']);
  30. });
  31. Tab::configureUsing(static function (Tab $tab) {
  32. $label = $tab->getLabel();
  33. if ($label) {
  34. $translatedLabel = translate($label);
  35. $tab->label(ucwords($translatedLabel));
  36. }
  37. }, isImportant: true);
  38. Section::configureUsing(static function (Section $section): void {
  39. $heading = $section->getHeading();
  40. if ($heading) {
  41. $translatedHeading = translate($heading);
  42. $section->heading(ucfirst($translatedHeading));
  43. }
  44. }, isImportant: true);
  45. ResourcesTab::configureUsing(static function (ResourcesTab $tab): void {
  46. $tab->localizeLabel();
  47. }, isImportant: true);
  48. ConfigureCurrencies::syncCurrencies();
  49. }
  50. }