added a help system, replaced the words "tenant" and "Pwa" with better alternatives. corrected and implemented cron jobs. prepared going live on a coolify-powered system.

This commit is contained in:
Codex Agent
2025-11-10 16:23:09 +01:00
parent ba9e64dfcb
commit 447a90a742
123 changed files with 6398 additions and 153 deletions

View File

@@ -0,0 +1,24 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class CoolifyActionLog extends Model
{
use HasFactory;
protected $guarded = [];
protected $casts = [
'payload' => 'array',
'response' => 'array',
];
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
}

View File

@@ -3,11 +3,13 @@
namespace App\Models;
use App\Services\EventJoinTokenService;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Facades\Crypt;
class Event extends Model
{
@@ -22,6 +24,13 @@ class Event extends Model
'is_active' => 'boolean',
'name' => 'array',
'description' => 'array',
'photobooth_enabled' => 'boolean',
'photobooth_expires_at' => 'datetime',
'photobooth_metadata' => 'array',
];
protected $hidden = [
'photobooth_password_encrypted',
];
protected static function booted(): void
@@ -159,4 +168,26 @@ class Event extends Model
$this->attributes['settings'] = json_encode($value ?? []);
}
public function getPhotoboothPasswordAttribute(): ?string
{
$encrypted = $this->attributes['photobooth_password_encrypted'] ?? null;
if (! $encrypted) {
return null;
}
try {
return Crypt::decryptString($encrypted);
} catch (DecryptException) {
return null;
}
}
public function setPhotoboothPasswordAttribute(?string $value): void
{
$this->attributes['photobooth_password_encrypted'] = $value
? Crypt::encryptString($value)
: null;
}
}

View File

@@ -6,17 +6,29 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use App\Models\EventMediaAsset;
use Illuminate\Support\Facades\Schema;
use Znck\Eloquent\Relations\BelongsToThrough as BelongsToThroughRelation;
use Znck\Eloquent\Traits\BelongsToThrough;
class Photo extends Model
{
use HasFactory;
use BelongsToThrough;
use HasFactory;
public const SOURCE_GUEST_PWA = 'guest_pwa';
public const SOURCE_TENANT_ADMIN = 'tenant_admin';
public const SOURCE_PHOTOBOOTH = 'photobooth';
public const SOURCE_UNKNOWN = 'unknown';
protected static ?array $columnCache = null;
protected $table = 'photos';
protected $guarded = [];
protected $casts = [
'is_featured' => 'boolean',
'metadata' => 'array',
@@ -26,6 +38,7 @@ class Photo extends Model
protected $attributes = [
'security_scan_status' => 'pending',
'ingest_source' => self::SOURCE_GUEST_PWA,
];
public function mediaAsset(): BelongsTo
@@ -63,6 +76,20 @@ class Photo extends Model
return $this->hasMany(PhotoLike::class);
}
public static function supportsFilenameColumn(): bool
{
return static::hasColumn('filename');
}
public static function hasColumn(string $column): bool
{
if (static::$columnCache === null) {
static::$columnCache = Schema::getColumnListing((new self)->getTable());
}
return in_array($column, static::$columnCache, true);
}
public function tenant(): BelongsToThroughRelation
{
return $this->belongsToThrough(

View File

@@ -0,0 +1,49 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
class PhotoboothSetting extends Model
{
protected $guarded = [];
protected $casts = [
'require_ftps' => 'boolean',
'allowed_ip_ranges' => 'array',
];
protected static function booted(): void
{
static::saved(fn () => static::flushCache());
static::deleted(fn () => static::flushCache());
}
public static function current(): self
{
return Cache::remember('photobooth.settings', now()->addMinutes(10), function () {
$defaults = [
'ftp_port' => config('photobooth.ftp.port', 2121),
'rate_limit_per_minute' => config('photobooth.rate_limit_per_minute', 20),
'expiry_grace_days' => config('photobooth.expiry_grace_days', 1),
'require_ftps' => false,
'allowed_ip_ranges' => null,
'control_service_base_url' => config('photobooth.control_service.base_url'),
'control_service_token_identifier' => null,
];
return static::query()->firstOrCreate(['id' => 1], $defaults);
});
}
public static function flushCache(): void
{
Cache::forget('photobooth.settings');
}
public function ftpHost(): ?string
{
return config('photobooth.ftp.host');
}
}