Adding Custom domains (#247)

* WIP

* wip

* Finished doing most of the work
This commit is contained in:
Julien Nahum
2023-11-29 14:53:08 +01:00
committed by GitHub
parent 57fdfb25a0
commit b50f579155
33 changed files with 1210 additions and 267 deletions

View File

@@ -14,10 +14,13 @@ class Workspace extends Model
const MAX_FILE_SIZE_FREE = 5000000; // 5 MB
const MAX_FILE_SIZE_PRO = 50000000; // 50 MB
const MAX_DOMAIN_PRO = 1;
protected $fillable = [
'name',
'icon',
'user_id',
'custom_domain',
];
protected $appends = [
@@ -25,6 +28,10 @@ class Workspace extends Model
'is_enterprise'
];
protected $casts = [
'custom_domains' => 'array',
];
public function getIsProAttribute()
{
if(is_null(config('cashier.key'))){
@@ -60,6 +67,26 @@ class Workspace extends Model
return self::MAX_FILE_SIZE_FREE;
}
public function getCustomDomainCountLimitAttribute()
{
if(is_null(config('cashier.key'))){
return null;
}
// Return max file size depending on subscription
foreach ($this->owners as $owner) {
if ($owner->is_subscribed) {
if ($license = $owner->activeLicense()) {
// In case of special License
return $license->custom_domain_limit_count;
}
}
return self::MAX_DOMAIN_PRO;
}
return 0;
}
public function getIsEnterpriseAttribute()
{
if(is_null(config('cashier.key'))){