tmyers273 / laravel-stripe-billing

3 stars 0 forks source link

Possible additional field for Plan model #7

Open denismitr opened 6 years ago

denismitr commented 6 years ago

Hi, Tom!

/**
* Allows us to later return a variable number depending on the current Plan
*
* @return int
*/
public function getConcurrencyCap(): int {
    // @todo resolve this number via the Plan
    return 3;
}

Just thinking here, we can solve this in different ways:

  1. via config, just by making an array of plan names and the cap.
  2. by overriding Plan table and the model in rocket-analytics
  3. or by adding json data field into the parent Plan model (here in this package), so that arbitrary data could be stored there, like various caps. I have a package for that: https://github.com/denismitr/laravel-json-attributes it already has been tried in laravel-event-recorder package and works well
denismitr commented 6 years ago

Using https://github.com/denismitr/laravel-json-attributes can also serve to dynamically add a list of priviledges that each plan offers

tmyers273 commented 6 years ago
  1. via config, just by making an array of plan names and the cap.

I am liking this option the best. It keeps the application specific limits in a centralized place and seems like it would be the cleanest way to accomplish.

// config/plans.php

return [
    'bronze' => [
        'concurrency_cap' => 1,
    ],
    'silver' => [
        'concurrency_cap' => 2,
    ],
    'gold' => [
        'concurrency_cap' => 10,
    ],
];

or something along those lines. Maybe this?

// config/plans.php

return [
    'concurrency_cap' => [
        'bronze' => 1.
        'silver' => 2,
        'gold' => 10,
    ],
]