gerardojbaez / laraplans

SaaS style recurring plans for Laravel.
http://laraplans.readthedocs.io
MIT License
180 stars 81 forks source link

Can't subscribe user to plan #33

Closed Yahav closed 6 years ago

Yahav commented 6 years ago

When executing the following code: $user = Auth::user(); $plan = Plan::find(1); $user->newSubscription('Free', $plan)->create();

I'm getting the following errors: Illuminate \ Database \ QueryException (22007) SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '2117-03-21 15:18:06' for column 'ends_at' at row 1 (SQL: insert intoplan_subscriptions(plan_id,trial_ends_at,name,subscribable_id,subscribable_type,starts_at,ends_at,updated_at,created_at) values (1, , Free, 1, App\Models\User, 2018-03-21 15:18:06, 2117-03-21 15:18:06, 2018-03-21 15:18:06, 2018-03-21 15:18:06))

Yahav commented 6 years ago

Found the error, i set the plan to:

'interval' => 'year',
'interval_count' => 99,

which caused this issue. changed it to 20 and it works

EDIT: didn't solved the issue apparently:

SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '2038-03-26 08:00:31' for column 'ends_at' at row 1 (SQL: insert into plan_subscriptions (plan_id, trial_ends_at, name, subscribable_id, subscribable_type, starts_at, ends_at, updated_at, created_at) values (6, , Free, 1, App\Models\User, 2018-03-26 08:00:31, 2038-03-26 08:00:31, 2018-03-26 08:00:31, 2018-03-26 08:00:31))

EDIT: So, setting it to 3 years did solve the issue, this whole thing is an extension of the following: https://github.com/gerardojbaez/laraplans/issues/32

This can be closed.