lucasdotvin/laravel-soulbscription

LucasDotVin\Soulbscription\Enums\PeriodicityType::getDateDifference(): Argument #3 ($unit) must be of type string, null given, called in /home/schneider/Code/tonote/vendor/lucasdotvin/laravel-soulbscription/src/Models/Concerns/HandlesRecurrence.php on line 20

Schneidershades opened this issue ยท 7 comments

LucasDotVin\Soulbscription\Enums\PeriodicityType::getDateDifference(): Argument #3 ($unit) must be of type string, null given, called in /home/schneider/Code/tonote/vendor/lucasdotvin/laravel-soulbscription/src/Models/Concerns/HandlesRecurrence.php on line 20

Hey! Thanks for reporting this bug! Could you provide some details? I'm gonna work to publish a release today to fix it if possible. ๐Ÿค˜

@lucasdotvin thank you when i try to implement the it returns the error
$subscriber->consume('Number of Users', 1);

it returns the error

Oh, so it is thrown when you try to consume a feature... Could you send me some screenshots of how your plans are configured? ๐Ÿ˜…

@lucasdotvin

Was trying to record in my model observers that the user team has consumed one feature to add user based on attached plan_features

Screenshot from 2022-07-21 22-52-14

$basic = Plan::create([
'name' => 'Basic',
'role' => 'User',
'description' => 'Basic',
'type' => 'Subscription',
'amount' => 0,
'periodicity' => 1,
'periodicity_type' => PeriodicityType::Month,
]);

    $pro = Plan::create([
        'name'                      => 'Pro',
        'role'                      => 'User',
        'description'               => 'Pro',
        'type'                      => 'Subscription',
        'amount'                    => 9900,
        'periodicity'               => 1,
        'periodicity_type'          => PeriodicityType::Month,
    ]);

    $business = Plan::create([
        'name'                      => 'Business',
        'role'                      => 'User',
        'description'               => 'Business',
        'type'                      => 'Subscription',
        'amount'                    => 19900,
        'periodicity'               => 1,
        'periodicity_type'          => PeriodicityType::Month,
    ]);

$usersFeature = Feature::where('name', 'Number of Users')->first();
$envelopsFeature = Feature::where('name', 'Number of Envelops')->first();
$trailFeature = Feature::where('name', 'Access to audit trail')->first();
$sealFeature = Feature::where('name', 'Digitise, Signature, Stamp and Seal')->first();
$brandingFeature = Feature::where('name', 'Personal Branding')->first();
$smsFeature = Feature::where('name', 'SMS Notifications')->first();

    $basic->features()->attach($usersFeature, ['charges' => 1]);
    $pro->features()->attach($usersFeature, ['charges' => 3]);
    $business->features()->attach($usersFeature, ['charges' => 10]);

    $basic->features()->attach($envelopsFeature, ['charges' => 10]);
    $pro->features()->attach($envelopsFeature, ['charges' => 50]);
    $business->features()->attach($envelopsFeature, ['charges' => 100]);

    $basic->features()->attach($trailFeature);
    $pro->features()->attach($trailFeature);
    $business->features()->attach($trailFeature);

    $basic->features()->attach($sealFeature);
    $pro->features()->attach($sealFeature);
    $business->features()->attach($sealFeature);


    $business->features()->attach($brandingFeature);
    $business->features()->attach($smsFeature);

Hi! I tried to replicate the bug locally, but everything ran as expected. Could you send me a screenshot of the seeder in which you registered the features? ๐Ÿ˜…

Hi! I tried to replicate the bug locally, but everything ran as expected. Could you send me a screenshot of the seeder in which you registered the features? ๐Ÿ˜…

Hi @lucasdotvin it occurs if you try to consume a feature whose periodicity_type is null