I am trying to get the end_date of Stripe subscription.
I have in my view:
@if (Auth::user()->subscription('main')->onGracePeriod())
<p> Your subscription will end on: {{ Auth::user()->subscribed('main')->ends_at }}</p>
@endif
And obviously that is not working because I get:
Call to a member function ends_at() on boolean
My User Class:
class User extends Authenticatable
{
use Notifiable, EntrustUserTrait, Billable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
protected $dates = [
'trial_ends_at'
];
}
My migrations so you have an idea on the tables:
public function up()
{
Schema::table('users', function ($table) {
$table->string('stripe_id')->nullable();
$table->string('card_brand')->nullable();
$table->string('card_last_four')->nullable();
$table->timestamp('trial_ends_at')->nullable();
});
Schema::create('subscriptions', function ($table) {
$table->increments('id');
$table->integer('user_id');
$table->string('name');
$table->string('stripe_id');
$table->string('stripe_plan');
$table->integer('quantity');
$table->timestamp('trial_ends_at')->nullable();
$table->timestamp('ends_at')->nullable();
$table->timestamps();
});
}
Again looking for end_date listed in the subscriptions table in the DB. I could always query it using this table but wanted to see if there was a better solution.
Thanks