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

@@ -53,6 +53,7 @@ class Form extends Model
'visibility',
// Customization
'custom_domain',
'theme',
'width',
'cover_picture',
@@ -141,12 +142,15 @@ class Form extends Model
public function getShareUrlAttribute()
{
return url('/forms/'.$this->slug);
if ($this->custom_domain) {
return 'https://' . $this->custom_domain . '/forms/' . $this->slug;
}
return url('/forms/' . $this->slug);
}
public function getEditUrlAttribute()
{
return url('/forms/'.$this->slug.'/show');
return url('/forms/' . $this->slug . '/show');
}
public function getSubmissionsCountAttribute()
@@ -156,12 +160,12 @@ class Form extends Model
public function getViewsCountAttribute()
{
if(env('DB_CONNECTION') == 'pgsql') {
if (env('DB_CONNECTION') == 'pgsql') {
return $this->views()->count() +
$this->statistics()->sum(DB::raw("cast(data->>'views' as integer)"));
} elseif(env('DB_CONNECTION') == 'mysql') {
$this->statistics()->sum(DB::raw("cast(data->>'views' as integer)"));
} elseif (env('DB_CONNECTION') == 'mysql') {
return (int)($this->views()->count() +
$this->statistics()->sum(DB::raw("json_extract(data, '$.views')")));
$this->statistics()->sum(DB::raw("json_extract(data, '$.views')")));
}
return 0;
}
@@ -219,7 +223,8 @@ class Form extends Model
return !empty($this->password);
}
protected function removedProperties(): Attribute {
protected function removedProperties(): Attribute
{
return Attribute::make(
get: function ($value) {
return $value ? json_decode($value, true) : [];
@@ -283,7 +288,7 @@ class Form extends Model
{
return !empty($this->webhook_url);
}
public function getNotifiesDiscordAttribute()
{
return !empty($this->discord_webhook_url);