The canUseFeature method is returning the first record in the database instead of filtering based on the slug. This is because the query is being applied to a fresh instance of the model that hasn't been properly utilized to build the query before first() is called in the function below in the SubscriptionUsage.php class
The tap(new $model()) simply returns the model instance itself. The where('slug', $featureSlug) method is then called, but since first() is immediately called on this query, it ends up executing the query before any further conditions are applied.
Instead of using tap(), you should directly chain the query methods on the model instance:
The
canUseFeature
method is returning the first record in the database instead of filtering based on theslug
. This is because the query is being applied to a fresh instance of the model that hasn't been properly utilized to build the query beforefirst()
is called in the function below in theSubscriptionUsage.php
classThe
tap(new $model())
simply returns the model instance itself. Thewhere('slug', $featureSlug)
method is then called, but sincefirst()
is immediately called on this query, it ends up executing the query before any further conditions are applied.Instead of using
tap()
, you should directly chain the query methods on the model instance:$feature = $model::where('slug', $featureSlug)->first();