From 1e1b8fa836a282dcbbab29e6c3d57add11efedba Mon Sep 17 00:00:00 2001 From: ninjaparade Date: Thu, 21 Dec 2023 11:29:50 -0800 Subject: [PATCH] wip --- config/stripe-data.php | 2 ++ .../create_stripe_data_table.php.stub | 1 + src/Models/StripeCustomer.php | 17 +++++++++++++++++ src/Models/StripePrice.php | 4 ---- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/config/stripe-data.php b/config/stripe-data.php index 70e7f15..4bf5046 100644 --- a/config/stripe-data.php +++ b/config/stripe-data.php @@ -10,4 +10,6 @@ 'stripe_account' => env('STRIPE_ACCOUNT', null), 'client_id' => env('STRIPE_CLIENT_ID', null), ], + + 'customer_class' => null, ]; diff --git a/database/migrations/create_stripe_data_table.php.stub b/database/migrations/create_stripe_data_table.php.stub index 5430a56..bc6bdf9 100644 --- a/database/migrations/create_stripe_data_table.php.stub +++ b/database/migrations/create_stripe_data_table.php.stub @@ -11,6 +11,7 @@ return new class extends Migration Schema::create('stripe_customers', function (Blueprint $table) { $table->id(); $table->string('name'); + $table->foreignId('account_id')->nullable()->index(); $table->string('email')->nullable(); $table->integer('balance')->default(0); $table->string('stripe_id'); diff --git a/src/Models/StripeCustomer.php b/src/Models/StripeCustomer.php index ae8d7c7..2ff3734 100644 --- a/src/Models/StripeCustomer.php +++ b/src/Models/StripeCustomer.php @@ -3,6 +3,7 @@ namespace Ninjaparade\StripeData\Models; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; use Ninjaparade\StripeData\Models\Casts\StripInvoiceSettingCast; class StripeCustomer extends Model @@ -23,4 +24,20 @@ class StripeCustomer extends Model 'balance' => 0, 'delinquent' => false, ]; + + public function tenant(): BelongsTo + { + return $this->belongsTo( + config('stripe-data.tenant_model'), + 'tenant_id' + ); + } + + public function account(): BelongsTo + { + return $this->belongsTo( + config('stripe-data.customer_model'), + 'account_id' + ); + } } diff --git a/src/Models/StripePrice.php b/src/Models/StripePrice.php index 2035647..38b5b7c 100644 --- a/src/Models/StripePrice.php +++ b/src/Models/StripePrice.php @@ -14,14 +14,10 @@ class StripePrice extends Model protected $casts = [ 'type' => BillingType::class, - // 'unit_amount' => 'integer', - // 'recurring' => 'array', 'recurring' => 'json', 'metadata' => 'json', - // 'active' => 'boolean', ]; - // protected $attributes = [ 'metadata' => [], 'recurring' => [],