lucasdotvin / laravel-soulbscription

A straightforward interface to handle subscriptions and feature consumption.
https://soulbscription.lucas.vin
MIT License
581 stars 79 forks source link

The models defined in config/soulbscription.php are not compatible with HasSubscriptions trait #61

Open mezbilisim opened 1 year ago

mezbilisim commented 1 year ago

When I define a new model for the plan in config/soulbscription.php, I cannot use some properties because these relationships are not defined in HasSubscriptions trait. For example, I can list the plans like this:

config('soulbscription.models.plan')::all();

But I can't change a plan that I have listed in this way.

$new_plan = config('soulbscription.models.plan')::find($plan_id);
$user->switchTo($new_plan);

Because dynamic relationship is not used in HasSubscriptions trait.

<?php

namespace LucasDotVin\Soulbscription\Models\Concerns;

use LucasDotVin\Soulbscription\Models\Plan;
.
.
.

trait HasSubscriptions
{

.
.
.

public function subscribeTo(Plan $plan, $expiration = null, $startDate = null): Subscription
    {
        .
        .
        .
    }
}

I want to customise the plan table. I can add price, description, currency or different discriminator fields. I can associate this model with my invoices. I want to make many more customisations like this.

bestiony commented 8 months ago

using your own models in its config file renders this package useless. better keep using the original models especially the Feature model