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

Ronster's avatar

Custom plans

Hi,

Does anyone knows if it's possible to create custom plans in Spark? I mean if a user requests a plan that is not available for all users.

Thanks, Regards, Ronnie

0 likes
10 replies
dr.dave2@gmail.com's avatar

I am looking for the same resource, like a dynamic plan that can be generated dynamically.

Ronster's avatar

I have done with adding spark plans in the service provider dynamically via database.

Works perfect!

1 like
jekinney's avatar

Create a table with the required columns. Out put the query in a foreach loop. Done. Gotta think on your feet!

1 like
Ronster's avatar

Exactly,

Make sure the price you enter is cast to a double otherwise all your prices go times 10...

1 like
EventFellows's avatar

That's easy for all the properties where the value from the dabase would go in as an argument. But how to add ->yearly() method if 'interval' => 'yearly'? Same goes for ->archived() for example.

        $plansDB = DatabasePlan::all();         
        
        foreach($plansDB as $plan)
        {
            Spark::Plan($plan->name, $plan->slug)
                ->price($plan->price)
                ->maxTeams($plan->maxTeams)
                // How to add ->yearly() OR -> archived() depending on DB value???
            ;
        }

An isset() inline statement does not work and if() also does not work.

Is there an elegant way beyond nesting foreach loops for all cases?

Ronster's avatar

how about

$plan = Spark::Plan($plan->name, $plan->slug)
                ->price($plan->price)
                ->maxTeams($plan->maxTeams);
$plan->archived();

not sure, but think it would work

1 like
EventFellows's avatar

@Ronster

Good idea, it does work in fact - with some minor twists (the 2 variables must be different). Here is a working setup for future use.

$plansDB = DatabasePlan::all();         

foreach($plansDB as $plan)
{
    $sparkPlan = Spark::Plan($plan->name, $plan->slug)
        ->price($plan->price)
        ->maxTeams($plan->maxTeams)
    ;
    $plan->interval == 'yearly' ? $sparkPlan->yearly() : ''; 
    $plan->archived == true ? $sparkPlan->archived() : ''; 
} 
Radiosilent's avatar

Could this possibly work to allow Dynamic pricing based on the number of Records in a mysaql database? For example, if one of my clients has 5,000 employees in my sequel, I need to be able to charge them 5000 times $0.10 equals $500.

Me_abhi's avatar

Please tell me how i create custom daily plan in laravel spark.

Please or to participate in this conversation.