Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

cg's avatar
Level 1

Changing controller method

Hello , I want to change the store method in Settings/Subscription/PlanController , In the docs I've seen the swap method I have tried it nothing happend : Spark::swap('PlanController@store', function ($request) {// new code} I'm not sure that this is the right way of doing it I've seen some examples , and I'm a bit confused on how to use it

0 likes
6 replies
cg's avatar
Level 1

when a user subscribes to a plan the route spark uses is /subscription I checked the method that corresponds to that route it's store in PlanController , I want at that exact moment to add a number of credits to a user depending on the plan he chose , I have a column credits in my users table , so I want to change the method (keep the existing code and add some lines to it )

martinbean's avatar
Level 80

@cg you’d be better off adding a listener to the UserSubscribed event that adds the credits, rather than trying to re-write Spark’s core registration method.

cg's avatar
Level 1

@martinbean thank you for bringing this idea up, I'll give a try. It seems a more cleaner solution.

Please or to participate in this conversation.