feat: disable custom script for trial users (#371)
* feat: disable custom script for trial users * fix: logic error for trial users --------- Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
@@ -28,6 +28,7 @@ class Workspace extends Model implements CachableAttributes
|
||||
|
||||
protected $appends = [
|
||||
'is_pro',
|
||||
'is_trialing',
|
||||
'is_enterprise',
|
||||
];
|
||||
|
||||
@@ -107,6 +108,24 @@ class Workspace extends Model implements CachableAttributes
|
||||
});
|
||||
}
|
||||
|
||||
public function getIsTrialingAttribute()
|
||||
{
|
||||
if (is_null(config('cashier.key'))) {
|
||||
return false; // If no paid plan so FALSE for ALL
|
||||
}
|
||||
|
||||
return $this->remember('is_trialing', 15 * 60, function (): bool {
|
||||
// Make sure at least one owner is pro
|
||||
foreach ($this->owners as $owner) {
|
||||
if ($owner->onTrial()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
public function getIsEnterpriseAttribute()
|
||||
{
|
||||
if (is_null(config('cashier.key'))) {
|
||||
|
||||
Reference in New Issue
Block a user