Admin Menü neu geordnet.
Introduced a two-tier media pipeline with dynamic disks, asset tracking, admin controls, and alerting around
upload/archival workflows.
- Added storage metadata + asset tables and models so every photo/variant knows where it lives
(database/migrations/2025_10_20_090000_create_media_storage_targets_table.php, database/ migrations/2025_10_20_090200_create_event_media_assets_table.php, app/Models/MediaStorageTarget.php:1, app/
Models/EventMediaAsset.php:1, app/Models/EventStorageAssignment.php:1, app/Models/Event.php:27).
- Rewired guest and tenant uploads to pick the event’s hot disk, persist EventMediaAsset records, compute
checksums, and clean up on delete (app/Http/Controllers/Api/EventPublicController.php:243, app/Http/
Controllers/Api/Tenant/PhotoController.php:25, app/Models/Photo.php:25).
- Implemented storage services, archival job scaffolding, monitoring config, and queue-failure notifications for upload issues (app/Services/Storage/EventStorageManager.php:16, app/Services/Storage/
StorageHealthService.php:9, app/Jobs/ArchiveEventMediaAssets.php:16, app/Providers/AppServiceProvider.php:39, app/Notifications/UploadPipelineFailed.php:8, config/storage-monitor.php:1).
- Seeded default hot/cold targets and exposed super-admin tooling via a Filament resource and capacity widget (database/seeders/MediaStorageTargetSeeder.php:13, database/seeders/DatabaseSeeder.php:17, app/Filament/Resources/MediaStorageTargetResource.php:1, app/Filament/Widgets/StorageCapacityWidget.php:12, app/Providers/Filament/SuperAdminPanelProvider.php:47).
- Dropped cron skeletons and artisan placeholders to schedule storage monitoring, archival dispatch, and upload queue health checks (cron/storage_monitor.sh, cron/archive_dispatcher.sh, cron/upload_queue_health.sh, routes/console.php:9).
This commit is contained in:
@@ -7,6 +7,9 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use App\Models\EventStorageAssignment;
|
||||
use App\Models\EventMediaAsset;
|
||||
use App\Models\MediaStorageTarget;
|
||||
|
||||
class Event extends Model
|
||||
{
|
||||
@@ -21,6 +24,27 @@ class Event extends Model
|
||||
'description' => 'array',
|
||||
];
|
||||
|
||||
public function storageAssignments(): HasMany
|
||||
{
|
||||
return $this->hasMany(EventStorageAssignment::class);
|
||||
}
|
||||
|
||||
public function mediaAssets(): HasMany
|
||||
{
|
||||
return $this->hasMany(EventMediaAsset::class);
|
||||
}
|
||||
|
||||
public function currentStorageTarget(?string $role = 'hot'): ?MediaStorageTarget
|
||||
{
|
||||
$assignment = $this->storageAssignments()
|
||||
->where('role', $role)
|
||||
->where('status', 'active')
|
||||
->latest('assigned_at')
|
||||
->first();
|
||||
|
||||
return $assignment?->storageTarget;
|
||||
}
|
||||
|
||||
public function tenant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Tenant::class);
|
||||
|
||||
54
app/Models/EventMediaAsset.php
Normal file
54
app/Models/EventMediaAsset.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class EventMediaAsset extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'event_id',
|
||||
'media_storage_target_id',
|
||||
'photo_id',
|
||||
'variant',
|
||||
'disk',
|
||||
'path',
|
||||
'size_bytes',
|
||||
'checksum',
|
||||
'mime_type',
|
||||
'status',
|
||||
'processed_at',
|
||||
'archived_at',
|
||||
'restored_at',
|
||||
'error_message',
|
||||
'meta',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'size_bytes' => 'integer',
|
||||
'processed_at' => 'datetime',
|
||||
'archived_at' => 'datetime',
|
||||
'restored_at' => 'datetime',
|
||||
'meta' => 'array',
|
||||
];
|
||||
|
||||
public function event(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Event::class);
|
||||
}
|
||||
|
||||
public function storageTarget(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(MediaStorageTarget::class, 'media_storage_target_id');
|
||||
}
|
||||
|
||||
public function photo(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Photo::class);
|
||||
}
|
||||
}
|
||||
|
||||
39
app/Models/EventStorageAssignment.php
Normal file
39
app/Models/EventStorageAssignment.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class EventStorageAssignment extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'event_id',
|
||||
'media_storage_target_id',
|
||||
'role',
|
||||
'status',
|
||||
'assigned_at',
|
||||
'released_at',
|
||||
'meta',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'assigned_at' => 'datetime',
|
||||
'released_at' => 'datetime',
|
||||
'meta' => 'array',
|
||||
];
|
||||
|
||||
public function event(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Event::class);
|
||||
}
|
||||
|
||||
public function storageTarget(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(MediaStorageTarget::class, 'media_storage_target_id');
|
||||
}
|
||||
}
|
||||
|
||||
66
app/Models/MediaStorageTarget.php
Normal file
66
app/Models/MediaStorageTarget.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class MediaStorageTarget extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'key',
|
||||
'name',
|
||||
'driver',
|
||||
'config',
|
||||
'is_hot',
|
||||
'is_default',
|
||||
'is_active',
|
||||
'priority',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'config' => 'array',
|
||||
'is_hot' => 'boolean',
|
||||
'is_default' => 'boolean',
|
||||
'is_active' => 'boolean',
|
||||
'priority' => 'integer',
|
||||
];
|
||||
|
||||
public function scopeActive(Builder $query): Builder
|
||||
{
|
||||
return $query->where('is_active', true);
|
||||
}
|
||||
|
||||
public function scopeHot(Builder $query): Builder
|
||||
{
|
||||
return $query->where('is_hot', true);
|
||||
}
|
||||
|
||||
public function eventAssignments(): HasMany
|
||||
{
|
||||
return $this->hasMany(EventStorageAssignment::class);
|
||||
}
|
||||
|
||||
public function mediaAssets(): HasMany
|
||||
{
|
||||
return $this->hasMany(EventMediaAsset::class);
|
||||
}
|
||||
|
||||
public function toFilesystemConfig(): array
|
||||
{
|
||||
$config = $this->config ?? [];
|
||||
|
||||
$base = [
|
||||
'driver' => $this->driver,
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
];
|
||||
|
||||
return array_merge($base, $config);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ 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 Znck\Eloquent\Relations\BelongsToThrough as BelongsToThroughRelation;
|
||||
use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
|
||||
@@ -21,6 +22,11 @@ class Photo extends Model
|
||||
'metadata' => 'array',
|
||||
];
|
||||
|
||||
public function mediaAsset(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(EventMediaAsset::class, 'media_asset_id');
|
||||
}
|
||||
|
||||
public function getImagePathAttribute(): ?string
|
||||
{
|
||||
return $this->file_path;
|
||||
|
||||
Reference in New Issue
Block a user