mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-app.git
synced 2026-06-11 02:50:29 +00:00
✨ 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:
@@ -0,0 +1,38 @@
|
||||
<?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:snapshot {meetup? : ID eines einzelnen Meetups; ohne Angabe werden alle Meetups gesichert}')]
|
||||
#[Description('Save the current master data of meetups as a restore point (restore_point JSON column).')]
|
||||
class SnapshotMeetupRestorePoints extends Command
|
||||
{
|
||||
public function handle(): int
|
||||
{
|
||||
$meetupId = $this->argument('meetup');
|
||||
|
||||
$count = 0;
|
||||
Meetup::query()
|
||||
->when($meetupId, fn ($query) => $query->whereKey($meetupId))
|
||||
->chunkById(200, function ($meetups) use (&$count) {
|
||||
foreach ($meetups as $meetup) {
|
||||
$meetup->captureRestorePoint();
|
||||
$count++;
|
||||
}
|
||||
});
|
||||
|
||||
if ($meetupId && $count === 0) {
|
||||
$this->error("Meetup [{$meetupId}] not found.");
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$this->info("Restore points saved for {$count} meetups.");
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user