Andrew Wallo 5 meses atrás
pai
commit
c5cb2fbd2a

+ 2
- 1
app/Filament/Company/Clusters/Settings/Pages/CompanyProfile.php Ver arquivo

@@ -201,7 +201,8 @@ class CompanyProfile extends Page
201 201
                 Hidden::make('type')
202 202
                     ->default('general'),
203 203
                 AddressFields::make()
204
-                    ->softRequired(),
204
+                    ->softRequired()
205
+                    ->disabledCountry(is_demo_environment()),
205 206
             ])
206 207
             ->columns(2);
207 208
     }

+ 1
- 1
app/Filament/Company/Clusters/Settings/Pages/Localization.php Ver arquivo

@@ -126,7 +126,7 @@ class Localization extends Page
126 126
                     ->softRequired()
127 127
                     ->localizeLabel()
128 128
                     ->options(LocalizationModel::getAllLanguages())
129
-                    ->disabled(app()->environment('demo'))
129
+                    ->disabled(is_demo_environment())
130 130
                     ->searchable(),
131 131
                 Select::make('timezone')
132 132
                     ->softRequired()

+ 1
- 1
app/Filament/Company/Pages/Reports/BaseReportPage.php Ver arquivo

@@ -227,7 +227,7 @@ abstract class BaseReportPage extends Page
227 227
                     ->action(fn () => $this->exportCSV()),
228 228
                 Action::make('exportPDF')
229 229
                     ->label('PDF')
230
-                    ->hidden(app()->environment('demo'))
230
+                    ->hidden(is_demo_environment())
231 231
                     ->action(fn () => $this->exportPDF()),
232 232
             ])
233 233
                 ->label('Export')

+ 2
- 2
app/Filament/Company/Resources/Purchases/VendorResource/Pages/CreateVendor.php Ver arquivo

@@ -2,14 +2,14 @@
2 2
 
3 3
 namespace App\Filament\Company\Resources\Purchases\VendorResource\Pages;
4 4
 
5
-use App\Concerns\RedirectToListPage;
5
+use App\Concerns\RedirectToViewPage;
6 6
 use App\Filament\Company\Resources\Purchases\VendorResource;
7 7
 use Filament\Resources\Pages\CreateRecord;
8 8
 use Filament\Support\Enums\MaxWidth;
9 9
 
10 10
 class CreateVendor extends CreateRecord
11 11
 {
12
-    use RedirectToListPage;
12
+    use RedirectToViewPage;
13 13
 
14 14
     protected static string $resource = VendorResource::class;
15 15
 

+ 2
- 2
app/Filament/Company/Resources/Sales/EstimateResource/Pages/CreateEstimate.php Ver arquivo

@@ -3,7 +3,7 @@
3 3
 namespace App\Filament\Company\Resources\Sales\EstimateResource\Pages;
4 4
 
5 5
 use App\Concerns\ManagesLineItems;
6
-use App\Concerns\RedirectToListPage;
6
+use App\Concerns\RedirectToViewPage;
7 7
 use App\Filament\Company\Resources\Sales\EstimateResource;
8 8
 use App\Models\Accounting\Estimate;
9 9
 use App\Models\Common\Client;
@@ -15,7 +15,7 @@ use Livewire\Attributes\Url;
15 15
 class CreateEstimate extends CreateRecord
16 16
 {
17 17
     use ManagesLineItems;
18
-    use RedirectToListPage;
18
+    use RedirectToViewPage;
19 19
 
20 20
     protected static string $resource = EstimateResource::class;
21 21
 

+ 16
- 0
app/Filament/Forms/Components/AddressFields.php Ver arquivo

@@ -2,6 +2,7 @@
2 2
 
3 3
 namespace App\Filament\Forms\Components;
4 4
 
5
+use Closure;
5 6
 use Filament\Forms\Components\Field;
6 7
 use Filament\Forms\Components\Grid;
7 8
 use Filament\Forms\Components\TextInput;
@@ -10,6 +11,8 @@ class AddressFields extends Grid
10 11
 {
11 12
     protected bool $isSoftRequired = false;
12 13
 
14
+    protected bool | Closure $isCountryDisabled = false;
15
+
13 16
     protected function setUp(): void
14 17
     {
15 18
         parent::setUp();
@@ -23,6 +26,7 @@ class AddressFields extends Grid
23 26
                 ->label('Address line 2')
24 27
                 ->maxLength(255),
25 28
             CountrySelect::make('country_code')
29
+                ->disabled(fn () => $this->isCountryDisabled())
26 30
                 ->clearStateField()
27 31
                 ->required(),
28 32
             StateSelect::make('state_id'),
@@ -55,4 +59,16 @@ class AddressFields extends Grid
55 59
             }
56 60
         }
57 61
     }
62
+
63
+    public function disabledCountry(bool | Closure $condition = true): static
64
+    {
65
+        $this->isCountryDisabled = $condition;
66
+
67
+        return $this;
68
+    }
69
+
70
+    public function isCountryDisabled(): bool
71
+    {
72
+        return $this->evaluate($this->isCountryDisabled);
73
+    }
58 74
 }

+ 0
- 1
app/Filament/Forms/Components/CountrySelect.php Ver arquivo

@@ -17,7 +17,6 @@ class CountrySelect extends Select
17 17
         $this
18 18
             ->localizeLabel('Country')
19 19
             ->searchable()
20
-            ->disabled(app()->environment('demo'))
21 20
             ->options($options = Country::getAvailableCountryOptions())
22 21
             ->getSearchResultsUsing(static fn (string $search): array => Country::getSearchResultsUsing($search))
23 22
             ->getOptionLabelUsing(static fn (string $value): ?string => $options[$value] ?? $value);

+ 1
- 1
app/Filament/Pages/Auth/Login.php Ver arquivo

@@ -10,7 +10,7 @@ class Login extends BaseLogin
10 10
     {
11 11
         parent::mount();
12 12
 
13
-        if (app()->environment('demo')) {
13
+        if (is_demo_environment()) {
14 14
             $this->form->fill([
15 15
                 'email' => 'admin@erpsaas.com',
16 16
                 'password' => 'password',

+ 1
- 1
app/Filament/User/Clusters/Account.php Ver arquivo

@@ -20,7 +20,7 @@ class Account extends Cluster
20 20
 
21 21
     public static function canAccess(): bool
22 22
     {
23
-        return ! app()->environment('demo');
23
+        return ! is_demo_environment();
24 24
     }
25 25
 
26 26
     /**

app/Helpers/format.php → app/Helpers/helpers.php Ver arquivo

@@ -122,3 +122,10 @@ if (! function_exists('rateFormat')) {
122 122
         return null;
123 123
     }
124 124
 }
125
+
126
+if (! function_exists('is_demo_environment')) {
127
+    function is_demo_environment(): bool
128
+    {
129
+        return app()->environment('demo');
130
+    }
131
+}

+ 1
- 1
app/Models/User.php Ver arquivo

@@ -71,7 +71,7 @@ class User extends Authenticatable implements FilamentUser, HasAvatar, HasDefaul
71 71
 
72 72
     public function canAccessPanel(Panel $panel): bool
73 73
     {
74
-        if ($panel->getId() === 'user' && app()->environment('demo')) {
74
+        if ($panel->getId() === 'user' && is_demo_environment()) {
75 75
             return false;
76 76
         }
77 77
 

+ 6
- 6
app/Policies/CompanyPolicy.php Ver arquivo

@@ -31,7 +31,7 @@ class CompanyPolicy
31 31
      */
32 32
     public function create(User $user): bool
33 33
     {
34
-        if (app()->environment('demo')) {
34
+        if (is_demo_environment()) {
35 35
             return false;
36 36
         }
37 37
 
@@ -43,7 +43,7 @@ class CompanyPolicy
43 43
      */
44 44
     public function update(User $user, Company $company): bool
45 45
     {
46
-        if (app()->environment('demo')) {
46
+        if (is_demo_environment()) {
47 47
             return false;
48 48
         }
49 49
 
@@ -55,7 +55,7 @@ class CompanyPolicy
55 55
      */
56 56
     public function addCompanyEmployee(User $user, Company $company): bool
57 57
     {
58
-        if (app()->environment('demo')) {
58
+        if (is_demo_environment()) {
59 59
             return false;
60 60
         }
61 61
 
@@ -67,7 +67,7 @@ class CompanyPolicy
67 67
      */
68 68
     public function updateCompanyEmployee(User $user, Company $company): bool
69 69
     {
70
-        if (app()->environment('demo')) {
70
+        if (is_demo_environment()) {
71 71
             return false;
72 72
         }
73 73
 
@@ -79,7 +79,7 @@ class CompanyPolicy
79 79
      */
80 80
     public function removeCompanyEmployee(User $user, Company $company): bool
81 81
     {
82
-        if (app()->environment('demo')) {
82
+        if (is_demo_environment()) {
83 83
             return false;
84 84
         }
85 85
 
@@ -91,7 +91,7 @@ class CompanyPolicy
91 91
      */
92 92
     public function delete(User $user, Company $company): bool
93 93
     {
94
-        if (app()->environment('demo')) {
94
+        if (is_demo_environment()) {
95 95
             return false;
96 96
         }
97 97
 

+ 1
- 1
app/Providers/Filament/CompanyPanelProvider.php Ver arquivo

@@ -79,7 +79,7 @@ class CompanyPanelProvider extends PanelProvider
79 79
      */
80 80
     public function panel(Panel $panel): Panel
81 81
     {
82
-        $isDemoEnvironment = app()->environment('demo');
82
+        $isDemoEnvironment = is_demo_environment();
83 83
 
84 84
         return $panel
85 85
             ->default()

+ 1
- 1
app/Services/CurrencyService.php Ver arquivo

@@ -21,7 +21,7 @@ class CurrencyService implements CurrencyHandler
21 21
      */
22 22
     public function isEnabled(): bool
23 23
     {
24
-        if (app()->environment('demo')) {
24
+        if (is_demo_environment()) {
25 25
             return false;
26 26
         }
27 27
 

+ 1
- 1
app/Services/PlaidService.php Ver arquivo

@@ -63,7 +63,7 @@ class PlaidService
63 63
      */
64 64
     public function isEnabled(): bool
65 65
     {
66
-        if (app()->environment('demo') || empty($this->clientId) || empty($this->clientSecret)) {
66
+        if (is_demo_environment() || empty($this->clientId) || empty($this->clientSecret)) {
67 67
             return false;
68 68
         }
69 69
 

+ 1
- 1
composer.json Ver arquivo

@@ -48,7 +48,7 @@
48 48
             "Database\\Seeders\\": "database/seeders/"
49 49
         },
50 50
         "files": [
51
-            "app/Helpers/format.php"
51
+            "app/Helpers/helpers.php"
52 52
         ]
53 53
     },
54 54
     "autoload-dev": {

Carregando…
Cancelar
Salvar