Estoy tratando de obtener la fecha de finalización de la suscripción a Stripe.
Tengo en mi opinión:
@if (Auth::user()->subscription('main')->onGracePeriod()) <p> Your subscription will end on: {{ Auth::user()->subscribed('main')->ends_at }}</p> @endifY obviamente eso no funciona porque obtengo:
Call to a member function ends_at() on booleanMi clase de usuario:
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' ]; }Mis migraciones para que tengas una idea sobre las tablas:
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(); }); }Nuevamente, busque la fecha de finalización que figura en la tabla de suscripciones en la base de datos. Siempre podía consultarlo usando esta tabla, pero quería ver si había una solución mejor.
Gracias