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

rameezisrar's avatar

Overriding the Spark Controllers

I need to change the logic used in the Spark Controllers. Can I make the controllers publish into my App/http/controllers directory just like another vendor package?

0 likes
10 replies
rameezisrar's avatar

@bobbybouwmann thankyou for sharing this link. That could be one option but honestly, that is tiresome. When I do vendor: publish command I get this output

....
[18] Tag: spark-full
  [19] Tag: spark-js
  [20] Tag: spark-lang
  [21] Tag: spark-sass
  [22] Tag: spark-views
.....

I think Spark-full will publish everything in the respective directories if it does then whenever I need to change a specific function I will go to published file.

bobbybouwmann's avatar

Will it publish all the controllers as well? I though the publish part was only for the assets!

martinbean's avatar

@abudo The login controller just uses the AuthenticatesUsers trait under the hood, which has many points to hook in to the login process.

What specifically is it you’re wanting to do? As you shouldn’t need to override the controller itself.

rameezisrar's avatar

@bobbybouwmann well even with spark-full option, i was only able to get assets publish :) so no controllers got published

rameezisrar's avatar

@martinbean Actually I need to override the Spark Controller because I need to change how the subscription work. Consider this scenario: I have 5 Products that I want to sell on subscription. Spark makes it use as Plans, right. But spark allows me only to switch from one plan to another while I need to make a user subscribe to other products at the same. i.e The user has subscribed to 5 products at the same times instead of one. How can I achieve that? I need to change the functionality of controllers of the Spark, right? First, how can I override the Spark controllers and where to place those controllers so I can update Spark later in the future?

bobbybouwmann's avatar

So like I said, you just need to register the route yourself and extend the SparkController ;)

1 like
martinbean's avatar

@abudo It sounds like you want to use “quantities”, which Spark up to version 5 supports (see the “Team Events” heading on https://spark.laravel.com/docs/5.0/teams).

If you’re using Spark 6, then you can use “per seat” pricing where you actually charge per product rather than “seat”: https://spark.laravel.com/docs/6.0/billing#charging-per-seat (see “Custom Per Seat Targets” header).

You really shouldn’t need to change any of the PHP code in Spark.

1 like
rameezisrar's avatar

@martinbean Quantity is something else. What I need is multiple subscriptions for a user as right now Spark allows only one subscription for a user. So I need to alter the Spark Controller

martinbean's avatar

@abudo A billable entity (user or team) can have multiple subscriptions. You don’t need to alter Spark’s code.

Please or to participate in this conversation.