Lint PHP code psr-12, add GH action
This commit is contained in:
@@ -10,10 +10,13 @@ class AiFormCompletion extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
const STATUS_PENDING = 'pending';
|
||||
const STATUS_PROCESSING = 'processing';
|
||||
const STATUS_COMPLETED = 'completed';
|
||||
const STATUS_FAILED = 'failed';
|
||||
public const STATUS_PENDING = 'pending';
|
||||
|
||||
public const STATUS_PROCESSING = 'processing';
|
||||
|
||||
public const STATUS_COMPLETED = 'completed';
|
||||
|
||||
public const STATUS_FAILED = 'failed';
|
||||
|
||||
protected $table = 'ai_form_completions';
|
||||
|
||||
@@ -21,11 +24,11 @@ class AiFormCompletion extends Model
|
||||
'form_prompt',
|
||||
'status',
|
||||
'result',
|
||||
'ip'
|
||||
'ip',
|
||||
];
|
||||
|
||||
protected $attributes = [
|
||||
'status' => self::STATUS_PENDING
|
||||
'status' => self::STATUS_PENDING,
|
||||
];
|
||||
|
||||
protected static function booted()
|
||||
|
||||
@@ -9,26 +9,31 @@ use App\Models\Traits\CachesAttributes;
|
||||
use App\Models\User;
|
||||
use App\Models\Workspace;
|
||||
use Database\Factories\FormFactory;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
use Spatie\Sluggable\HasSlug;
|
||||
use Spatie\Sluggable\SlugOptions;
|
||||
use Stevebauman\Purify\Facades\Purify;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
|
||||
class Form extends Model implements CachableAttributes
|
||||
{
|
||||
use CachesAttributes;
|
||||
|
||||
const DARK_MODE_VALUES = ['auto', 'light', 'dark'];
|
||||
const THEMES = ['default', 'simple', 'notion'];
|
||||
const WIDTHS = ['centered', 'full'];
|
||||
const VISIBILITY = ['public', 'draft', 'closed'];
|
||||
use HasFactory;
|
||||
use HasSlug;
|
||||
use SoftDeletes;
|
||||
|
||||
use HasFactory, HasSlug, SoftDeletes;
|
||||
public const DARK_MODE_VALUES = ['auto', 'light', 'dark'];
|
||||
|
||||
public const THEMES = ['default', 'simple', 'notion'];
|
||||
|
||||
public const WIDTHS = ['centered', 'full'];
|
||||
|
||||
public const VISIBILITY = ['public', 'draft', 'closed'];
|
||||
|
||||
protected $fillable = [
|
||||
'workspace_id',
|
||||
@@ -94,7 +99,7 @@ class Form extends Model implements CachableAttributes
|
||||
'password',
|
||||
|
||||
// Custom SEO
|
||||
'seo_meta'
|
||||
'seo_meta',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
@@ -104,7 +109,7 @@ class Form extends Model implements CachableAttributes
|
||||
'tags' => 'array',
|
||||
'removed_properties' => 'array',
|
||||
'seo_meta' => 'object',
|
||||
'notification_settings' => 'object'
|
||||
'notification_settings' => 'object',
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
@@ -127,13 +132,13 @@ class Form extends Model implements CachableAttributes
|
||||
'password',
|
||||
'tags',
|
||||
'notification_emails',
|
||||
'removed_properties'
|
||||
'removed_properties',
|
||||
];
|
||||
|
||||
protected $cachableAttributes = [
|
||||
'is_pro',
|
||||
'views_count',
|
||||
'max_file_size'
|
||||
'max_file_size',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -155,14 +160,15 @@ class Form extends Model implements CachableAttributes
|
||||
public function getShareUrlAttribute()
|
||||
{
|
||||
if ($this->custom_domain) {
|
||||
return 'https://' . $this->custom_domain . '/forms/' . $this->slug;
|
||||
return 'https://'.$this->custom_domain.'/forms/'.$this->slug;
|
||||
}
|
||||
return front_url('/forms/' . $this->slug);
|
||||
|
||||
return front_url('/forms/'.$this->slug);
|
||||
}
|
||||
|
||||
public function getEditUrlAttribute()
|
||||
{
|
||||
return front_url('/forms/' . $this->slug . '/show');
|
||||
return front_url('/forms/'.$this->slug.'/show');
|
||||
}
|
||||
|
||||
public function getSubmissionsCountAttribute()
|
||||
@@ -174,9 +180,10 @@ class Form extends Model implements CachableAttributes
|
||||
{
|
||||
return $this->remember('views_count', 15 * 60, function (): int {
|
||||
if (env('DB_CONNECTION') == 'mysql') {
|
||||
return (int)($this->views()->count() +
|
||||
return (int) ($this->views()->count() +
|
||||
$this->statistics()->sum(DB::raw("json_extract(data, '$.views')")));
|
||||
}
|
||||
|
||||
return $this->views()->count() +
|
||||
$this->statistics()->sum(DB::raw("cast(data->>'views' as integer)"));
|
||||
});
|
||||
@@ -204,20 +211,21 @@ class Form extends Model implements CachableAttributes
|
||||
|
||||
public function getIsClosedAttribute()
|
||||
{
|
||||
return ($this->closes_at && now()->gt($this->closes_at));
|
||||
return $this->closes_at && now()->gt($this->closes_at);
|
||||
}
|
||||
|
||||
public function getFormPendingSubmissionKeyAttribute()
|
||||
{
|
||||
if ($this->updated_at?->timestamp) {
|
||||
return "openform-" . $this->id . "-pending-submission-" . substr($this->updated_at?->timestamp, -6);
|
||||
return 'openform-'.$this->id.'-pending-submission-'.substr($this->updated_at?->timestamp, -6);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getMaxNumberOfSubmissionsReachedAttribute()
|
||||
{
|
||||
return ($this->max_submissions_count && $this->max_submissions_count <= $this->submissions_count);
|
||||
return $this->max_submissions_count && $this->max_submissions_count <= $this->submissions_count;
|
||||
}
|
||||
|
||||
public function setClosedTextAttribute($value)
|
||||
@@ -232,12 +240,12 @@ class Form extends Model implements CachableAttributes
|
||||
|
||||
public function getHasPasswordAttribute()
|
||||
{
|
||||
return !empty($this->password);
|
||||
return ! empty($this->password);
|
||||
}
|
||||
|
||||
public function getMaxFileSizeAttribute()
|
||||
{
|
||||
return $this->remember('max_file_size', 15 * 60, function(): int {
|
||||
return $this->remember('max_file_size', 15 * 60, function (): int {
|
||||
return $this->workspace->max_file_size;
|
||||
});
|
||||
}
|
||||
@@ -292,7 +300,7 @@ class Form extends Model implements CachableAttributes
|
||||
return SlugOptions::create()
|
||||
->doNotGenerateSlugsOnUpdate()
|
||||
->generateSlugsFrom(function (Form $form) {
|
||||
return $form->title . ' ' . Str::random(6);
|
||||
return $form->title.' '.Str::random(6);
|
||||
})
|
||||
->saveSlugsTo('slug');
|
||||
}
|
||||
@@ -302,19 +310,18 @@ class Form extends Model implements CachableAttributes
|
||||
return FormFactory::new();
|
||||
}
|
||||
|
||||
|
||||
public function getNotifiesWebhookAttribute()
|
||||
{
|
||||
return !empty($this->webhook_url);
|
||||
return ! empty($this->webhook_url);
|
||||
}
|
||||
|
||||
public function getNotifiesDiscordAttribute()
|
||||
{
|
||||
return !empty($this->discord_webhook_url);
|
||||
return ! empty($this->discord_webhook_url);
|
||||
}
|
||||
|
||||
public function getNotifiesSlackAttribute()
|
||||
{
|
||||
return !empty($this->slack_webhook_url);
|
||||
return ! empty($this->slack_webhook_url);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,20 +2,19 @@
|
||||
|
||||
namespace App\Models\Forms;
|
||||
|
||||
use App\Models\Forms\Form;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class FormStatistic extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'form_id',
|
||||
'data',
|
||||
'date'
|
||||
'date',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -34,5 +33,4 @@ class FormStatistic extends Model
|
||||
{
|
||||
return $this->belongsTo(Form::class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Models\Forms;
|
||||
|
||||
use App\Models\Forms\Form;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
@@ -11,17 +10,18 @@ class FormSubmission extends Model
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'data'
|
||||
'data',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'data' => 'array'
|
||||
'data' => 'array',
|
||||
];
|
||||
|
||||
/**
|
||||
* RelationShips
|
||||
*/
|
||||
public function form() {
|
||||
public function form()
|
||||
{
|
||||
return $this->belongsTo(Form::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Models\Forms;
|
||||
|
||||
use App\Models\Forms\Form;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
@@ -13,7 +12,8 @@ class FormView extends Model
|
||||
/**
|
||||
* RelationShips
|
||||
*/
|
||||
public function form() {
|
||||
public function form()
|
||||
{
|
||||
return $this->belongsTo(Form::class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user