diff --git a/app/Models/Subscription.php b/app/Models/Subscription.php index 7b588bddfc97..7c7679a82a9e 100644 --- a/app/Models/Subscription.php +++ b/app/Models/Subscription.php @@ -22,10 +22,9 @@ class Subscription extends BaseModel protected $fillable = [ 'user_id', - 'product_id', + 'product_ids', + 'recurring_product_ids', 'company_id', - 'product_id', - 'is_recurring', 'frequency_id', 'auto_bill', 'promo_code', @@ -43,6 +42,7 @@ class Subscription extends BaseModel 'refund_period', 'webhook_configuration', 'currency_id', + 'group_id', ]; protected $casts = [ diff --git a/database/migrations/2021_03_25_082025_refactor_billing_scriptions_table.php b/database/migrations/2021_03_25_082025_refactor_billing_scriptions_table.php index f944dc5596de..561f19db350f 100644 --- a/database/migrations/2021_03_25_082025_refactor_billing_scriptions_table.php +++ b/database/migrations/2021_03_25_082025_refactor_billing_scriptions_table.php @@ -21,10 +21,12 @@ class RefactorBillingScriptionsTable extends Migration $table->text('recurring_product_ids'); $table->string('name'); $table->unique(['company_id', 'name']); + $table->unsignedInteger('group_id'); }); Schema::table('subscriptions', function (Blueprint $table) { $table->renameColumn('product_id', 'product_ids'); + $table->dropColumn('is_recurring'); }); } diff --git a/tests/Feature/SubscriptionApiTest.php b/tests/Feature/SubscriptionApiTest.php index 49ca0d007987..f5b8e424f4fd 100644 --- a/tests/Feature/SubscriptionApiTest.php +++ b/tests/Feature/SubscriptionApiTest.php @@ -53,7 +53,7 @@ class SubscriptionApiTest extends TestCase ]); $billing_subscription = Subscription::factory()->create([ - 'product_id' => $product->id, + 'product_ids' => $product->id, 'company_id' => $this->company->id, ]); @@ -78,7 +78,7 @@ class SubscriptionApiTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/subscriptions', ['product_id' => $product->id, 'allow_cancellation' => true]); + ])->post('/api/v1/subscriptions', ['product_ids' => $product->id, 'allow_cancellation' => true]); $response->assertStatus(200); } @@ -92,7 +92,7 @@ class SubscriptionApiTest extends TestCase $response1 = $this ->withHeaders(['X-API-SECRET' => config('ninja.api_secret'),'X-API-TOKEN' => $this->token]) - ->post('/api/v1/subscriptions', ['product_id' => $product->id]) + ->post('/api/v1/subscriptions', ['product_ids' => $product->id]) ->assertStatus(200) ->json(); @@ -123,7 +123,7 @@ class SubscriptionApiTest extends TestCase ]); $billing_subscription = Subscription::factory()->create([ - 'product_id' => $product->id, + 'product_ids' => $product->id, 'company_id' => $this->company->id, ]);