Stripe サブスクリプションの end_date を取得しようとしています。
私の見解では:
@if (Auth::user()->subscription('main')->onGracePeriod())
<p> Your subscription will end on: {{ Auth::user()->subscribed('main')->ends_at }}</p>
@endif
そして、明らかにそれは機能していません。
Call to a member function ends_at() on boolean
私のユーザークラス:
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'
];
}
私の移行なので、テーブルについてのアイデアがあります:
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();
});
}
DB のサブスクリプション テーブルにリストされている end_date を再度探します。このテーブルを使用していつでもクエリを実行できましたが、より良い解決策があるかどうかを確認したかったのです。
ありがとう