I ended up adding Cashier to my existing project and doing it on my own. Mainly because the team billing feature wouldn't work unless you were using free trials, boss wouldn't have liked that.
Cashier, like Spark doesn't let you customise the foreign key name in the subscriptions table from user_id to in my case company_id but it lets you customise the model. I'm sure most people would be fine keeping it as user_id, it probably bothered more than it should have.
I made my own Subscription model to fix the issue:
<?php
namespace App;
use Laravel\Cashier\Subscription as BaseSubscription;
class Subscription extends BaseSubscription
{
public function user()
{
$model = getenv('BRAINTREE_MODEL') ?: config('services.braintree.model');
return $this->belongsTo($model, 'company_id');
}
public function company()
{
return $this->user();
}
public function getCompanyAttribute()
{
return $this->user;
}
}
And lastly, add this to the company model:
use Billable {
subscriptions as billableSubscriptions;
}
public function subscriptions()
{
return $this->hasMany(\App\Subscription::class)->orderBy('created_at', 'desc');
}