S2a: purge legacy Form Builder PHP code and routes
This commit is contained in:
@@ -85,11 +85,6 @@ final class Organisation extends Model
|
||||
return $this->hasMany(PersonTag::class);
|
||||
}
|
||||
|
||||
public function registrationFieldTemplates(): HasMany
|
||||
{
|
||||
return $this->hasMany(RegistrationFieldTemplate::class);
|
||||
}
|
||||
|
||||
public function emailSettings(): HasOne
|
||||
{
|
||||
return $this->hasOne(OrganisationEmailSettings::class);
|
||||
|
||||
@@ -105,11 +105,6 @@ final class Person extends Model
|
||||
return $this->hasMany(VolunteerAvailability::class);
|
||||
}
|
||||
|
||||
public function fieldValues(): HasMany
|
||||
{
|
||||
return $this->hasMany(PersonFieldValue::class);
|
||||
}
|
||||
|
||||
public function formSubmissions(): MorphMany
|
||||
{
|
||||
return $this->morphMany(\App\Models\FormBuilder\FormSubmission::class, 'subject');
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
final class PersonFieldValue extends Model
|
||||
{
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'person_id',
|
||||
'registration_form_field_id',
|
||||
'value',
|
||||
'selected_options',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'selected_options' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
public function person(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Person::class);
|
||||
}
|
||||
|
||||
public function registrationFormField(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(RegistrationFormField::class);
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\FieldDisplayWidth;
|
||||
use App\Enums\RegistrationFieldType;
|
||||
use App\Models\Scopes\OrganisationScope;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Concerns\HasUlids;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
final class RegistrationFieldTemplate extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use HasUlids;
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::addGlobalScope(new OrganisationScope());
|
||||
}
|
||||
|
||||
protected $fillable = [
|
||||
'organisation_id',
|
||||
'label',
|
||||
'slug',
|
||||
'field_type',
|
||||
'options',
|
||||
'tag_categories',
|
||||
'is_required',
|
||||
'is_filterable',
|
||||
'is_portal_visible',
|
||||
'is_admin_only',
|
||||
'help_text',
|
||||
'sort_order',
|
||||
'display_width',
|
||||
'is_system',
|
||||
'is_active',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'field_type' => RegistrationFieldType::class,
|
||||
'options' => 'array',
|
||||
'tag_categories' => 'array',
|
||||
'is_required' => 'boolean',
|
||||
'is_filterable' => 'boolean',
|
||||
'is_portal_visible' => 'boolean',
|
||||
'is_admin_only' => 'boolean',
|
||||
'sort_order' => 'integer',
|
||||
'display_width' => FieldDisplayWidth::class,
|
||||
'is_system' => 'boolean',
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
/** @return array<int, array{label: string, description: string|null}>|null */
|
||||
public function getNormalizedOptionsAttribute(): ?array
|
||||
{
|
||||
if ($this->options === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return collect($this->options)->map(function (mixed $option): array {
|
||||
if (is_string($option)) {
|
||||
return ['label' => $option, 'description' => null];
|
||||
}
|
||||
|
||||
return [
|
||||
'label' => $option['label'] ?? (string) $option,
|
||||
'description' => $option['description'] ?? null,
|
||||
];
|
||||
})->toArray();
|
||||
}
|
||||
|
||||
public function organisation(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Organisation::class);
|
||||
}
|
||||
|
||||
public function scopeActive(Builder $query): Builder
|
||||
{
|
||||
return $query->where('is_active', true);
|
||||
}
|
||||
|
||||
public function scopeSystem(Builder $query): Builder
|
||||
{
|
||||
return $query->where('is_system', true);
|
||||
}
|
||||
|
||||
public function scopeOrdered(Builder $query): Builder
|
||||
{
|
||||
return $query->orderBy('sort_order');
|
||||
}
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\FieldDisplayWidth;
|
||||
use App\Enums\RegistrationFieldType;
|
||||
use App\Models\Scopes\OrganisationScope;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Concerns\HasUlids;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
final class RegistrationFormField extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use HasUlids;
|
||||
|
||||
/** @var string Used by OrganisationScope to determine filtering strategy */
|
||||
public string $organisationScopeColumn = 'event_id';
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::addGlobalScope(new OrganisationScope());
|
||||
}
|
||||
|
||||
protected $fillable = [
|
||||
'event_id',
|
||||
'label',
|
||||
'slug',
|
||||
'field_type',
|
||||
'options',
|
||||
'tag_categories',
|
||||
'is_required',
|
||||
'is_portal_visible',
|
||||
'is_admin_only',
|
||||
'is_filterable',
|
||||
'help_text',
|
||||
'sort_order',
|
||||
'display_width',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'field_type' => RegistrationFieldType::class,
|
||||
'options' => 'array',
|
||||
'tag_categories' => 'array',
|
||||
'is_required' => 'boolean',
|
||||
'is_portal_visible' => 'boolean',
|
||||
'is_admin_only' => 'boolean',
|
||||
'is_filterable' => 'boolean',
|
||||
'sort_order' => 'integer',
|
||||
'display_width' => FieldDisplayWidth::class,
|
||||
];
|
||||
}
|
||||
|
||||
public function event(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Event::class);
|
||||
}
|
||||
|
||||
public function personFieldValues(): HasMany
|
||||
{
|
||||
return $this->hasMany(PersonFieldValue::class, 'registration_form_field_id');
|
||||
}
|
||||
|
||||
/** @return array<int, array{label: string, description: string|null}>|null */
|
||||
public function getNormalizedOptionsAttribute(): ?array
|
||||
{
|
||||
if ($this->options === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return collect($this->options)->map(function (mixed $option): array {
|
||||
if (is_string($option)) {
|
||||
return ['label' => $option, 'description' => null];
|
||||
}
|
||||
|
||||
return [
|
||||
'label' => $option['label'] ?? (string) $option,
|
||||
'description' => $option['description'] ?? null,
|
||||
];
|
||||
})->toArray();
|
||||
}
|
||||
|
||||
public function isMultiValue(): bool
|
||||
{
|
||||
return $this->field_type->isMultiValue();
|
||||
}
|
||||
|
||||
public function scopeOrdered(Builder $query): Builder
|
||||
{
|
||||
return $query->orderBy('sort_order');
|
||||
}
|
||||
|
||||
public function scopePortalVisible(Builder $query): Builder
|
||||
{
|
||||
return $query->where('is_portal_visible', true)->where('is_admin_only', false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user