Extract Ladill Events as a standalone events suite at events.ladill.com.
Deploy Ladill QR Plus / deploy (push) Successful in 28s
Deploy Ladill QR Plus / deploy (push) Successful in 28s
Full control center for ticketed events, contributions, attendees, badges, and programmes — not a QR utility clone. Includes SSO shell, import command, and platform cutover runbook. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Support\Qr\QrStyleDefaults;
|
||||
use App\Support\Qr\QrTypeCatalog;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/** Per-account QR Plus preferences (notifications and new-code defaults). */
|
||||
class QrSetting extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'notify_email',
|
||||
'product_updates',
|
||||
'low_balance_alerts',
|
||||
'default_type',
|
||||
'default_style',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'product_updates' => 'boolean',
|
||||
'low_balance_alerts' => 'boolean',
|
||||
'default_style' => 'array',
|
||||
];
|
||||
|
||||
/** @return list<string> */
|
||||
public static function storableStyleKeys(): array
|
||||
{
|
||||
return [
|
||||
'foreground',
|
||||
'background',
|
||||
'error_correction',
|
||||
'margin',
|
||||
'module_style',
|
||||
'finder_outer',
|
||||
'finder_inner',
|
||||
'frame_style',
|
||||
'frame_text',
|
||||
'frame_color',
|
||||
'gradient_type',
|
||||
'gradient_color1',
|
||||
'gradient_color2',
|
||||
'gradient_rotation',
|
||||
];
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function resolvedDefaultType(): string
|
||||
{
|
||||
$type = (string) ($this->default_type ?? QrCode::TYPE_EVENT);
|
||||
|
||||
return in_array($type, QrTypeCatalog::eventsTypes(), true) ? $type : QrCode::TYPE_EVENT;
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
public function resolvedDefaultStyle(): array
|
||||
{
|
||||
$stored = collect($this->default_style ?? [])
|
||||
->only(self::storableStyleKeys())
|
||||
->filter(fn ($value) => $value !== null && $value !== '')
|
||||
->all();
|
||||
|
||||
return QrStyleDefaults::merge($stored !== [] ? $stored : null);
|
||||
}
|
||||
|
||||
/** @param array<string, mixed>|null $input */
|
||||
public static function sanitizeDefaultStyle(?array $input): ?array
|
||||
{
|
||||
if ($input === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$merged = QrStyleDefaults::merge(
|
||||
collect($input)->only(self::storableStyleKeys())->all(),
|
||||
);
|
||||
|
||||
return collect($merged)->only(self::storableStyleKeys())->all();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user