Add restore_point functionality to Meetups

- 💾 Introduced `restore_point` JSON column in `meetups` table for saving and restoring master data.
- 🛠️ Added methods `captureRestorePoint` and `restoreFromRestorePoint` to `Meetup` model for managing restore points.
- 🔒 Implemented authorization for updating meetups via `updateViaPortal` policy to include pivot members.
- 🔗 Created Artisan commands `meetups:snapshot` and `meetups:restore` for managing restore points from CLI.
- 🚦 Added rate limiter to restrict excessive update attempts in Livewire meetup editing.
-  Developed exhaustive feature tests for snapshot and restore actions, portal editing rules, and rate limiting.
This commit is contained in:
HolgerHatGarKeineNode
2026-06-10 10:56:38 +02:00
parent 8c68b19138
commit f5cf85b438
9 changed files with 350 additions and 6 deletions
@@ -0,0 +1,36 @@
<?php
namespace App\Console\Commands\Database;
use App\Models\Meetup;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
#[Signature('meetups:restore {meetup : ID des wiederherzustellenden Meetups}')]
#[Description('Restore the master data of a meetup from its saved restore point.')]
class RestoreMeetupFromRestorePoint extends Command
{
public function handle(): int
{
$meetupId = $this->argument('meetup');
$meetup = Meetup::query()->find($meetupId);
if ($meetup === null) {
$this->error("Meetup [{$meetupId}] not found.");
return Command::FAILURE;
}
if (! $meetup->restoreFromRestorePoint()) {
$this->error("Meetup [{$meetup->id}] {$meetup->name} has no restore point. Run meetups:snapshot first.");
return Command::FAILURE;
}
$capturedAt = $meetup->restore_point['captured_at'] ?? 'unknown';
$this->info("Meetup [{$meetup->id}] {$meetup->name} restored from restore point (captured at {$capturedAt}).");
return Command::SUCCESS;
}
}