diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 01480db..648a70a 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -34,7 +34,7 @@ class UserController extends Controller $user->active = true; $user->password = Hash::make($request->password); $user->customer_id = Customer::create(['email' => - $request->email], 'metadata' => ['user_id' => $user->id])->id; + $request->email], 'name' => $request->name, 'metadata' => ['user_id' => $user->id])->id; $user->save(); event(new Registered($user)); @@ -100,8 +100,10 @@ class UserController extends Controller $validated = $request->validate([ 'name' => 'required|max:30' ]); + Stripe::setApiKey(env('STRIPE_SECRET')); $user = Auth::user(); $user->name = $request->name; + Customer::update($user->customer_id, ['name' => $request->name]); $user->save(); return $user; } @@ -120,6 +122,7 @@ class UserController extends Controller } public function resetEmail(Request $request) { + Stripe::setApiKey(env('STRIPE_SECRET')); if (! $request->hasValidSignature()) { abort(401); } @@ -135,6 +138,7 @@ class UserController extends Controller $user = User::find($request->user); $user->email = $request->email; $user->save(); + Customer::update($user->customer_id, ['name' => $request->email]); return view('email-changed'); }