Open syntx1997 opened 1 month ago
Sorry, I just want to give some updates about my investigation about this. I think it is something related to this: $user->planSubscription('main')->getFeatureRemainings('listings'); the value main is actually from the slug field from the subscriptions table.
Subscriptions table:
I have checked the planSubscription function inside the HasPlanSubscriptions trait and this is what I found. I think this is the main reason for this. It's just happen that I only tested one subscription on my local (which means there's only one subscription data there with main slug) thats why this bug didn't show up.
I solve it by overriding the function by recreating a function on my User model where the trait has been applied.
public function planSubscription(string $subscriptionSlug): ?Subscription { return $this->planSubscriptions()->where('slug', 'like', '%' . $subscriptionSlug . '%')->first(); }
Hi! I faced the same problem. It was an absolutely strange solution with unique slugs. I had to use my own class for features. I overwrite getSlugOptions function
public function getSlugOptions(): SlugOptions
{
return SlugOptions::create()
->doNotGenerateSlugsOnUpdate()
->generateSlugsFrom('name')
->saveSlugsTo('slug')
->extraScope(fn($builder) => $builder->where('plan_id', $this->plan_id));
}
And remove unique key for slug in DB. My solution allows you to make a unique slug for a separate plan.
Hello guys, I am really having trouble getting the user subscription, it always returns null even though the user was subscribed already, I have checked the sdubscriptions table on database and the user's id was there. It only happens on live server, no issue on local.