Hi.
I'm just trying to get the subscriptions working but I keep hitting this error,
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null in
Now I know it looks missing but that's all I'm doing so far is passing the data from vue to the controller and in the controller::
try {
$user = User::where('id', Auth::id())->with(['pricing'])->firstOrFail();
$duration = request('duration');
$stripeToken = request('stripeToken');
// Params 1. Product 2. Plan
$user->newSubscription($user->pricing->stripe_product_id, $duration . 'months')->create($stripeToken, [
'email' => $user->email,
]);
return response()->json(['status' => 'Your payment has been successful.'], 200);
} catch (\Exception $e) {
event(new NotifyIssues($user, $e));
$request->session()->flash('status', $e->getMessage());
$request->session()->flash('alert', 'danger');
return response()->json(['status' => $e->getMessage()], 422);
}
The Migration:
Schema::create('subscriptions', function ($table) {
$table->increments('id');
$table->unsignedInteger('user_id');
$table->string('name');
$table->string('stripe_id')->collation('utf8mb4_bin');
$table->string('stripe_plan');
$table->integer('quantity');
$table->timestamp('trial_ends_at')->nullable();
$table->timestamp('ends_at')->nullable();
$table->timestamps();
});
It creates the subscription in stripe and does the payment, but doesn't save to the subscriptions table.
Any ideas? Or more to the point, what am i missing?