Skip to content

Commit 811b787

Browse files
style: Fix code style with Laravel Pint
1 parent fd32c9c commit 811b787

File tree

114 files changed

+925
-1129
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+925
-1129
lines changed

app/Data/Stripe/StripeDataLoader.php

+17-19
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
<?php
22

3-
declare(strict_types=1);
3+
declare(strict_types = 1);
44

55
namespace App\Data\Stripe;
66

77
use App\Enums\Stripe\ProductIntervalEnum;
8+
use App\Models\{Price, Product, ProductFeature};
89
use Illuminate\Support\Collection;
9-
use App\Models\Product;
10-
use App\Models\Price;
11-
use App\Models\ProductFeature;
1210

1311
class StripeDataLoader
1412
{
@@ -23,33 +21,33 @@ public static function getProductsData(): Collection
2321

2422
->map(function (Product $product) {
2523
return [
26-
'id' => $product->id,
27-
'name' => $product->name,
24+
'id' => $product->id,
25+
'name' => $product->name,
2826
'description' => $product->description,
29-
'image' => $product->image,
30-
'stripe_id' => $product->stripe_id,
31-
'features' => $product->features->filter(function (ProductFeature $feature) {
27+
'image' => $product->image,
28+
'stripe_id' => $product->stripe_id,
29+
'features' => $product->features->filter(function (ProductFeature $feature) {
3230
return $feature->is_active == true;
3331
})->map(function (ProductFeature $feature) {
3432
return [
35-
'id' => $feature->id,
36-
'name' => $feature->name,
33+
'id' => $feature->id,
34+
'name' => $feature->name,
3735
'description' => $feature->description,
38-
'is_active' => $feature->is_active,
36+
'is_active' => $feature->is_active,
3937
];
4038
}),
4139
'prices' => $product->prices->filter(function (Price $price) {
4240
return $price->is_active == true;
4341
})->map(function (Price $price) {
4442
return [
45-
'id' => $price->id,
46-
'currency' => $price->currency->value,
47-
'interval' => ProductIntervalEnum::from($price->interval->value)->getlabel(),
43+
'id' => $price->id,
44+
'currency' => $price->currency->value,
45+
'interval' => ProductIntervalEnum::from($price->interval->value)->getlabel(),
4846
'interval_description' => ProductIntervalEnum::from($price->interval->value)->getDescription(),
49-
'unit_amount' => (int) $price->unit_amount,
50-
'stripe_price_id' => $price->stripe_price_id,
51-
'is_active' => $price->is_active,
52-
'trial_period_days' => (int) $price->trial_days,
47+
'unit_amount' => (int) $price->unit_amount,
48+
'stripe_price_id' => $price->stripe_price_id,
49+
'is_active' => $price->is_active,
50+
'trial_period_days' => (int) $price->trial_days,
5351
];
5452
}),
5553
];

app/Enums/Evolution/StatusConnectionEnum.php

+9-10
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,28 @@
66

77
enum StatusConnectionEnum: string implements HasLabel, HasColor
88
{
9-
case CLOSE = 'close';
10-
case OPEN = 'open';
9+
case CLOSE = 'close';
10+
case OPEN = 'open';
1111
case CONNECTING = 'connecting';
12-
case REFUSED = 'refused';
12+
case REFUSED = 'refused';
1313

1414
public function getLabel(): string
1515
{
1616
return match ($this) {
17-
self::OPEN => 'Conectado',
17+
self::OPEN => 'Conectado',
1818
self::CONNECTING => 'Conectando',
19-
self::CLOSE => 'Desconectado',
20-
self::REFUSED => 'Recusado',
19+
self::CLOSE => 'Desconectado',
20+
self::REFUSED => 'Recusado',
2121
};
2222
}
2323
public function getColor(): string|array|null
2424
{
2525
return match ($this) {
26-
self::OPEN => 'success',
26+
self::OPEN => 'success',
2727
self::CONNECTING => 'warning',
28-
self::CLOSE => 'danger',
29-
self::REFUSED => 'danger',
28+
self::CLOSE => 'danger',
29+
self::REFUSED => 'danger',
3030
};
3131
}
3232

33-
3433
}

app/Enums/Stripe/Refunds/ReasonRefundStatusEnum.php

+12-14
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,24 @@
77
enum ReasonRefundStatusEnum: string implements HasLabel
88
{
99
case CHARGE_FOR_PENDING_REFUND_DISPUTED = 'charge_for_pending_refund_disputed';
10-
case DECLINED = 'declined';
11-
case EXPIRED_OR_CANCELED_CARD = 'expired_or_canceled_card';
12-
case INSUFFICIENT_FUNDS = 'insufficient_funds';
13-
case LOST_OR_STOLEN_CARD = 'lost_or_stolen_card';
14-
case MERCANT_REQUEST = 'merchant_request';
15-
case UNKNOWN = 'unknown';
16-
10+
case DECLINED = 'declined';
11+
case EXPIRED_OR_CANCELED_CARD = 'expired_or_canceled_card';
12+
case INSUFFICIENT_FUNDS = 'insufficient_funds';
13+
case LOST_OR_STOLEN_CARD = 'lost_or_stolen_card';
14+
case MERCANT_REQUEST = 'merchant_request';
15+
case UNKNOWN = 'unknown';
1716

1817
public function getLabel(): string
1918
{
2019
return match ($this) {
2120
self::CHARGE_FOR_PENDING_REFUND_DISPUTED => 'Constestação de reembolso',
22-
self::DECLINED => 'Reembolso recusado',
23-
self::EXPIRED_OR_CANCELED_CARD => 'Expirada ou Cancelada',
24-
self::INSUFFICIENT_FUNDS => 'Saldo Insuficiente',
25-
self::LOST_OR_STOLEN_CARD => 'Perda ou roubo do cartão',
26-
self::MERCANT_REQUEST => 'Falha no reembolso',
27-
self::UNKNOWN => ' falhou por motivo desconhecido',
21+
self::DECLINED => 'Reembolso recusado',
22+
self::EXPIRED_OR_CANCELED_CARD => 'Expirada ou Cancelada',
23+
self::INSUFFICIENT_FUNDS => 'Saldo Insuficiente',
24+
self::LOST_OR_STOLEN_CARD => 'Perda ou roubo do cartão',
25+
self::MERCANT_REQUEST => 'Falha no reembolso',
26+
self::UNKNOWN => ' falhou por motivo desconhecido',
2827
};
2928
}
3029

31-
3230
}

app/Enums/Stripe/Refunds/RefundStatusEnum.php

+13-15
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,35 @@
22

33
namespace App\Enums\Stripe\Refunds;
44

5-
use Filament\Support\Contracts\HasColor;
6-
use Filament\Support\Contracts\HasLabel;
7-
5+
use Filament\Support\Contracts\{HasColor, HasLabel};
86

97
enum RefundStatusEnum: string implements HasLabel, HasColor
108
{
11-
case PENDING = 'pending';
9+
case PENDING = 'pending';
1210
case REQUIRES_ACTION = 'requires_action';
13-
case SUCCEEDED = 'succeeded';
14-
case FAILED = 'failed';
15-
case CANCELED = 'canceled';
11+
case SUCCEEDED = 'succeeded';
12+
case FAILED = 'failed';
13+
case CANCELED = 'canceled';
1614

1715
public function getLabel(): string
1816
{
1917
return match ($this) {
20-
self::PENDING => 'Pendente',
18+
self::PENDING => 'Pendente',
2119
self::REQUIRES_ACTION => 'Requer Ação',
22-
self::SUCCEEDED => 'Realizada',
23-
self::FAILED => 'Falhou',
24-
self::CANCELED => 'Cancelado',
20+
self::SUCCEEDED => 'Realizada',
21+
self::FAILED => 'Falhou',
22+
self::CANCELED => 'Cancelado',
2523
};
2624
}
2725

2826
public function getColor(): string|array|null
2927
{
3028
return match ($this) {
31-
self::PENDING => 'prymary',
29+
self::PENDING => 'prymary',
3230
self::REQUIRES_ACTION => 'warning',
33-
self::SUCCEEDED => 'success',
34-
self::FAILED => 'danger',
35-
self::CANCELED => 'danger',
31+
self::SUCCEEDED => 'success',
32+
self::FAILED => 'danger',
33+
self::CANCELED => 'danger',
3634
};
3735
}
3836
}

app/Enums/Stripe/Refunds/RefundSubscriptionEnum.php

+10-12
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,31 @@
22

33
namespace App\Enums\Stripe\Refunds;
44

5-
use Filament\Support\Contracts\HasColor;
6-
use Filament\Support\Contracts\HasLabel;
7-
use Filament\Support\Contracts\HasDescription;
5+
use Filament\Support\Contracts\{HasColor, HasLabel};
86

97
enum RefundSubscriptionEnum: string implements HasLabel, HasColor
108
{
11-
case DUPLICATE = 'duplicate';
12-
case FRAUDULENT = 'fraudulent';
13-
case REQUESTED_BY_CUSTOMER = 'requested_by_customer';
9+
case DUPLICATE = 'duplicate';
10+
case FRAUDULENT = 'fraudulent';
11+
case REQUESTED_BY_CUSTOMER = 'requested_by_customer';
1412
case EXPIRED_UNCAPTURED_CHARGE = 'expired_uncaptured_charge';
1513

1614
public function getLabel(): string
1715
{
1816
return match ($this) {
19-
self::DUPLICATE => 'Duplicada',
20-
self::FRAUDULENT => 'Fraude',
21-
self::REQUESTED_BY_CUSTOMER => 'Solicitada pelo Cliente',
17+
self::DUPLICATE => 'Duplicada',
18+
self::FRAUDULENT => 'Fraude',
19+
self::REQUESTED_BY_CUSTOMER => 'Solicitada pelo Cliente',
2220
self::EXPIRED_UNCAPTURED_CHARGE => 'Cobrança Expirada',
2321
};
2422
}
2523

2624
public function getColor(): string|array|null
2725
{
2826
return match ($this) {
29-
self::DUPLICATE => 'success',
30-
self::FRAUDULENT => 'success',
31-
self::REQUESTED_BY_CUSTOMER => 'success',
27+
self::DUPLICATE => 'success',
28+
self::FRAUDULENT => 'success',
29+
self::REQUESTED_BY_CUSTOMER => 'success',
3230
self::EXPIRED_UNCAPTURED_CHARGE => 'success',
3331
};
3432
}

app/Filament/Actions/SubscribePlanAction.php

+47-44
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
<?php
22

3-
declare(strict_types=1);
3+
declare(strict_types = 1);
44

55
namespace App\Filament\Actions;
66

7-
use Closure;
8-
use Stripe\Stripe;
9-
use Illuminate\View\View;
10-
use Illuminate\Support\Arr;
7+
use App\Data\Stripe\StripeDataLoader;
8+
use App\Forms\Components\RadioGroup;
119
use App\Models\Organization;
10+
11+
use function App\Support\tenant;
12+
13+
use Closure;
1214
use Filament\Actions\Action;
13-
use Stripe\Checkout\Session;
14-
use Illuminate\Support\HtmlString;
15-
use App\Forms\Components\RadioGroup;
1615
use Filament\Support\Enums\MaxWidth;
17-
use App\Data\Stripe\StripeDataLoader;
1816
use Illuminate\Contracts\Support\Htmlable;
19-
use function App\Support\tenant;
17+
use Illuminate\Support\{Arr, HtmlString};
18+
use Illuminate\View\View;
19+
use Stripe\Checkout\Session;
20+
use Stripe\Stripe;
2021

2122
class SubscribePlanAction extends Action
2223
{
@@ -52,7 +53,7 @@ protected function setUp(): void
5253
->size('xl')
5354
->extraAttributes(['class' => 'w-full'])
5455
->action(function (Action $action) {
55-
$actions = $action->getLivewire()->mountedActionsData;
56+
$actions = $action->getLivewire()->mountedActionsData;
5657
$billingPeriod = data_get(Arr::first($actions), 'billing_period');
5758

5859
// Chama a função que cria a sessão de checkout e redireciona o usuário
@@ -81,6 +82,7 @@ protected function setUp(): void
8182
public function brandLogo(string | Htmlable | Closure | null $logo): static
8283
{
8384
$this->brandLogo = $logo;
85+
8486
return $this;
8587
}
8688

@@ -99,6 +101,7 @@ protected function getBilledPeriods(): array
99101
$products = StripeDataLoader::getProductsData();
100102

101103
$periods = [];
104+
102105
foreach ($products as $product) {
103106
foreach ($product['prices'] as $price) {
104107
$periods[$price['interval']] = ucfirst($price['interval']);
@@ -115,52 +118,52 @@ protected function getBilledPeriods(): array
115118
* @return void
116119
*/
117120
protected function checkoutUrl(string $billingPeriod): void
118-
{
119-
// Obtém a organização (tenant) atual
121+
{
122+
// Obtém a organização (tenant) atual
120123

124+
$organization = tenant(Organization::class);
121125

122-
$organization = tenant(Organization::class);
126+
if (!$organization->stripe_id) {
127+
throw new \Exception('A organização não possui um ID do Stripe associado.');
128+
}
123129

124-
if (!$organization->stripe_id) {
125-
throw new \Exception('A organização não possui um ID do Stripe associado.');
126-
}
130+
// Configura a API Key da Stripe
131+
Stripe::setApiKey(env('STRIPE_SECRET'));
127132

128-
// Configura a API Key da Stripe
129-
Stripe::setApiKey(env('STRIPE_SECRET'));
133+
// Obtém o produto e o preço com base no período de cobrança selecionado
134+
$products = StripeDataLoader::getProductsData();
135+
$priceId = null;
130136

131-
// Obtém o produto e o preço com base no período de cobrança selecionado
132-
$products = StripeDataLoader::getProductsData();
133-
$priceId = null;
137+
foreach ($products as $product) {
138+
foreach ($product['prices'] as $price) {
139+
if ($price['interval'] === $billingPeriod) {
140+
$priceId = $price['stripe_price_id']; // Garante que está pegando o ID do preço
134141

135-
foreach ($products as $product) {
136-
foreach ($product['prices'] as $price) {
137-
if ($price['interval'] === $billingPeriod) {
138-
$priceId = $price['stripe_price_id']; // Garante que está pegando o ID do preço
139-
break 2;
142+
break 2;
143+
}
140144
}
141145
}
142-
}
143146

144-
// Cria a sessão de checkout
145-
$checkoutSession = Session::create([
147+
// Cria a sessão de checkout
148+
$checkoutSession = Session::create([
146149

147-
'payment_method_types' => ['card'],
150+
'payment_method_types' => ['card'],
148151

149-
'mode' => 'subscription',
150-
'customer' => $organization->stripe_id, // Certifique-se de que a organização tenha um stripe_id
151-
'line_items' => [
152-
[
153-
'price' => $priceId, // Aqui vai o ID do objeto de preço
154-
'quantity' => 1,
152+
'mode' => 'subscription',
153+
'customer' => $organization->stripe_id, // Certifique-se de que a organização tenha um stripe_id
154+
'line_items' => [
155+
[
156+
'price' => $priceId, // Aqui vai o ID do objeto de preço
157+
'quantity' => 1,
158+
],
155159
],
156-
],
157-
'success_url' => url('/app'), // Redireciona para o dashboard do Filament
158-
'cancel_url' => url('/app'), // Redireciona para o dashboard caso o pagamento seja cancelado
160+
'success_url' => url('/app'), // Redireciona para o dashboard do Filament
161+
'cancel_url' => url('/app'), // Redireciona para o dashboard caso o pagamento seja cancelado
159162

160-
]);
163+
]);
161164

162-
// Redireciona para a URL de checkout
163-
redirect()->away($checkoutSession->url);
164-
}
165+
// Redireciona para a URL de checkout
166+
redirect()->away($checkoutSession->url);
167+
}
165168

166169
}

app/Filament/Admin/Resources/OrganizationResource/Pages/CreateOrganization.php

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace App\Filament\Admin\Resources\OrganizationResource\Pages;
44

55
use App\Filament\Admin\Resources\OrganizationResource;
6-
use Filament\Actions;
76
use Filament\Resources\Pages\CreateRecord;
87

98
class CreateOrganization extends CreateRecord

0 commit comments

Comments
 (0)