lucasdotvin / laravel-soulbscription

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

subscribeTo() with Custom Plan Model #89

Closed bulentsakarya closed 9 months ago

bulentsakarya commented 10 months ago

I've changed custom Plan model to my own model. I've changed config file settings, too..

When I assign users to plan with migration getting error.

App\Models\User\User::subscribeTo(): Argument #1 ($plan) must be of type LucasDotVin\Soulbscription\Models\Plan, App\Models\Admin\Plan given, called in C:\code\guard\database\seeders\DatabaseSeeder.php on line 183

at vendor\lucasdotvin\laravel-soulbscription\src\Models\Concerns\HasSubscriptions.php:120 116▕ 117▕ event(new FeatureConsumed($this, $feature, $featureConsumption)); 118▕ } 119▕ ➜ 120▕ public function subscribeTo(Plan $plan, $expiration = null, $startDate = null): Subscription 121▕ { 122▕ if ($plan->periodicity) { 123▕ $expiration = $expiration ?? $plan->calculateNextRecurrenceEnd($startDate); 124▕

1 database\seeders\DatabaseSeeder.php:183 App\Models\User\User::subscribeTo(Object(App\Models\Admin\Plan))

2 vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:36 Database\Seeders\DatabaseSeeder::run()

DatabaseSeeder.php on line 183 183 $freeuser->subscribeTo($free); 184 $standartuser->subscribeTo($standart); 185 $prouser->subscribeTo($pro);

ManuelDiazVarelis commented 10 months ago

Hello! Have you considered extending from LucasDotVin\Soulbscription\Models\Plan class? I manage to implement a custom plan this way while keeping most (if not all) "under the hood" stuff from the package

bulentsakarya commented 9 months ago

Hello! Have you considered extending from LucasDotVin\Soulbscription\Models\Plan class? I manage to implement a custom plan this way while keeping most (if not all) "under the hood" stuff from the package

Yes, I resolved the issue by expanding through the LucasDotVin\Soulbscription\Models\Plan model. Thank you.