Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
StyleCIBot committed Sep 12, 2024
1 parent 90693d2 commit 9c85883
Show file tree
Hide file tree
Showing 23 changed files with 42 additions and 45 deletions.
2 changes: 1 addition & 1 deletion app/GraphQL/Subscription/Builders/PlanBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ public function getPlans(
*/
return Plan::query();
}
}
}
2 changes: 1 addition & 1 deletion app/GraphQL/Subscription/Builders/SubscriptionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ public function getSubscriptions(
*/
return Subscription::query();
}
}
}
6 changes: 3 additions & 3 deletions app/GraphQL/Subscription/Mutations/Prices/PriceMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function create(array $req): PriceModel
]);

$stripePrice = StripePrice::create([
'unit_amount' => $req['input']['amount'] * 100,
'unit_amount' => $req['input']['amount'] * 100,
'currency' => $req['input']['currency'],
'recurring' => ['interval' => $req['input']['interval']],
'product' => $stripeProduct->id,
Expand All @@ -62,8 +62,8 @@ public function update(array $req): PriceModel

StripePrice::create([
'unit_amount' => $req['input']['amount'] * 100,
'currency' => $price->currency,
'recurring' => ['interval' => $price->interval],
'currency' => $price->currency,
'recurring' => ['interval' => $price->interval],
'product' => $price->stripe_id,
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public function __construct()
*/
public function create(array $req): SubscriptionItemModel
{

StripeSubscriptionItem::create([
'subscription' => $req['input']['subscription_id'],
'price' => $req['input']['stripe_price_id'],
Expand All @@ -53,7 +52,6 @@ public function create(array $req): SubscriptionItemModel
*/
public function update(array $req): SubscriptionItemModel
{

$subscriptionItem = SubscriptionItemRepository::getById($req['id']);

StripeSubscriptionItem::update($subscriptionItem->stripe_id, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Kanvas\Companies\Models\Companies;

class SubscriptionMutation
{
{
public function __construct()
{
Stripe::setApiKey(env('STRIPE_SECRET'));
Expand All @@ -32,9 +32,8 @@ public function __construct()
*/
public function create(array $req): SubscriptionModel
{

$company = Companies::findOrFail($req['input']['companies_id']);

$paymentMethodId = $req['input']['payment_method_id'];

$customer_id = $company->stripe_id ?? $this->createStripeCustomer($company, $paymentMethodId);
Expand All @@ -58,7 +57,6 @@ public function create(array $req): SubscriptionModel

public function update(array $req): SubscriptionModel
{

$subscription = SubscriptionModel::findOrFail($req['input']['id']);

$stripeSubscription = StripeSubscription::update($subscription->stripe_id, [
Expand All @@ -68,12 +66,13 @@ public function update(array $req): SubscriptionModel
'price' => $item['price_id'], // Nuevo price_id
];
}, $req['input']['items']),
]);;
]);
;

$dto = SubscriptionDto::viaRequest($req['input'], Auth::user(), $stripeSubscription);

(new UpdateSubscription($subscription, $dto))->execute();

return $subscription;
}

Expand Down Expand Up @@ -113,4 +112,4 @@ private function createStripeCustomer(Companies $company, string $paymentMethodI

return $customer->id;
}
}
}
1 change: 1 addition & 0 deletions app/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
use Kanvas\Users\Observers\UsersAssociatedAppsObserver;
use Kanvas\Users\Observers\UsersAssociatedCompaniesObserver;
use Kanvas\Users\Observers\UsersObserver;

//use Kanvas\Subscriptions\Subscription\Models\Subscription;
//use Kanvas\Subscriptions\Subscription\Observers\SubscriptionObserver;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('subscriptions', function (Blueprint $table) {
$table->string('payment_method_id')->nullable()->after('apps_plans_id');;
$table->string('payment_method_id')->nullable()->after('apps_plans_id');
;
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/Domains/Subscription/Models/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ public function trashed()
{
return $this->{$this->getDeletedAtColumn()};
}
}
}
2 changes: 1 addition & 1 deletion src/Domains/Subscription/Plans/Actions/CreatePlan.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ public function execute(): Plan
'users_id' => $this->dto->user->getId(),
]);
}
}
}
2 changes: 1 addition & 1 deletion src/Domains/Subscription/Plans/Actions/UpdatePlan.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ public function execute(): Plan

return $this->plan;
}
}
}
6 changes: 3 additions & 3 deletions src/Domains/Subscription/Plans/DataTransferObject/Plan.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(
public string $name,
public ?string $description = null,
public string $stripe_id,
public bool $is_default =false,
public bool $is_default = false,
public bool $is_deleted = false,
) {
}
Expand All @@ -32,10 +32,10 @@ public static function viaRequest(array $request, UserInterface $user): self
app(Apps::class),
auth()->user,
$request['name'],
$request['stripe_id'],
$request['stripe_id'],
$request['description'] ?? null,
$request['is_default'] ?? false,
$request['is_deleted'] ?? false
);
}
}
}
7 changes: 4 additions & 3 deletions src/Domains/Subscription/Plans/Models/Plan.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Kanvas\Apps\Models\Apps;
use Kanvas\Subscription\Models\BaseModel;
use Kanvas\Subscription\SubscriptionItems\Models\SubscriptionItem;

/**
* Class Plan.
*
Expand All @@ -26,15 +27,15 @@ class Plan extends BaseModel
{
protected $table = 'apps_plans';
protected $guarded = [];

/**
* apps.
*/
public function apps(): BelongsTo
{
return $this->belongsTo(Apps::class, 'apps_id');
}

/**
* subscriptionItem.
*/
Expand All @@ -52,4 +53,4 @@ public function trashed(): bool
{
return $this->{$this->getDeletedAtColumn()};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static function getModel(): Model
{
return new Price();
}

/**
* Get a price by its Stripe ID.
*
Expand All @@ -30,5 +30,4 @@ public static function getByStripeId(string $stripeId): Price
{
return Price::where('stripe_id', $stripeId)->firstOrFail();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ public function execute(): SubscriptionItem
'quantity' => $this->subscriptionItemDto->quantity,
]);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ public function execute(): SubscriptionItem

return $this->subscriptionItem;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(
public int $subscription_id,
public int $apps_plans_id,
public string $stripe_price_id,
public ?int $quantity = 1,
public ?int $quantity = 1,
) {
}

Expand All @@ -33,7 +33,7 @@ public static function viaRequest(array $request, UserInterface $user): self
$request['subscription_id'],
$request['apps_plans_id'],
$request['stripe_price_id'],
$request['quantity'] ?? 1,
$request['quantity'] ?? 1,
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SubscriptionItem extends BaseModel
{
protected $table = 'subscription_items';
protected $guarded = [];

/**
* subscription.
*/
Expand Down Expand Up @@ -60,4 +60,4 @@ public function trashed(): bool
{
return $this->{$this->getDeletedAtColumn()};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ public function execute(): Subscription

return $subscription;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
class UpdateSubscription
{
public function __construct(
protected Subscription $subscription,
protected Subscription $subscription,
protected SubscriptionDto $subscriptionDto
) {
}

public function execute(): Subscription
{

$this->subscription->update([
'name' => $this->subscriptionDto->name ?? $this->subscription->name,
'payment_method_id' => $this->subscriptionDto->payment_method_id ?? $this->subscription->payment_method_id,
Expand All @@ -28,4 +27,4 @@ public function execute(): Subscription

return $this->subscription;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public function __construct(
public bool $is_cancelled = false,
public bool $paid = false,
public ?string $charge_date = null,

) {
}

Expand All @@ -43,4 +42,4 @@ public static function viaRequest(array $request, UserInterface $user): self
$request['trial_days'] ?? null,
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
*/
class Subscription extends BaseModel
{

protected $table = 'subscriptions';
protected $guarded = [];

Expand Down Expand Up @@ -74,4 +73,4 @@ public function trashed(): bool
{
return $this->{$this->getDeletedAtColumn()};
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Kanvas\Subscriptions\Subscription\Observers;
Expand All @@ -16,4 +17,4 @@ public function updating(Subscription $subscription)
{
//
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Kanvas\Subscription\Subscriptions\Models\Subscription;
use Kanvas\Subscription\Subscriptions\DataTransferObject\Subscription as SubscriptionDto;

class SubscriptionRepository
{
public static function create(array $data): Subscription
Expand All @@ -19,4 +20,4 @@ public static function cancel(int $id): Subscription
$subscription->cancel();
return $subscription;
}
}
}

0 comments on commit 9c85883

Please sign in to comment.