I'm trying to create one more relationship with my subscriptions, the first one is user which is the billable model and it's working fine, the other one is place, which is the place the user owns.
I created a migration which adds the place_id:
Schema::table('subscriptions', function (Blueprint $table) {
$table->unsignedBigInteger('place_id')->nullable()->after('user_id');
$table->index('place_id');
});
I can't find a way to make the subscription->place relationship, where do i create it? The place->subscription relationship works fine. Do i create another model? With namespace Laravel\Cashier? Any ideas?
Create a normal model that extends Laravel\Cashier\Subscription
<?php
namespace App;
use Laravel\Cashier\Subscription as CashierSubscription;
class Subscription extends CashierSubscription
{
public function place()
{
return $this->belongsTo('App\Place');
}
public function plan()
{
return $this->belongsTo('App\Plan', 'stripe_plan', 'stripe_id');
}
public function getRenewsAtAttribute()
{
return Carbon::parse($this->asStripeSubscription()->current_period_end);
}
// ...
}