public function billingSave(Request $request)
{
$user = auth()->user();
$paymentMethod = $request->payment_method;
try {
if ($user->subscribed('basic')) {
$user->updateDefaultPaymentMethod($paymentMethod);
} else {
$plan = Plan::where('key', '=', $request['plan'])->first();
$user->plan_id = $plan->id;
$user->save();
$user->newSubscription('main', $request->plan)->create($paymentMethod, [
'name' => $user->name,
'email' => $user->email,
]);
}
} catch (\Exception $e) {
return back()->with(['alert' => 'Error updated your billing info', 'alert_type' => 'error']);
}
return back()->with(['alert' => 'Successfully updated your billing info', 'alert_type' => 'success']);
}
я тоже не понимаю, что ему тут не нравилось