- Tenant-Admin-PWA: Neues /event-admin/welcome Onboarding mit WelcomeHero, Packages-, Order-Summary- und Event-Setup-Pages, Zustandsspeicher, Routing-Guard und Dashboard-CTA für Erstnutzer; Filament-/admin-Login via Custom-View behoben.
- Brand/Theming: Marketing-Farb- und Typographievariablen in `resources/css/app.css` eingeführt, AdminLayout, Dashboardkarten und Onboarding-Komponenten entsprechend angepasst; Dokumentation (`docs/todo/tenant-admin-onboarding-fusion.md`, `docs/changes/...`) aktualisiert. - Checkout & Payments: Checkout-, PayPal-Controller und Tests für integrierte Stripe/PayPal-Flows sowie Paket-Billing-Abläufe überarbeitet; neue PayPal SDK-Factory und Admin-API-Helper (`resources/js/admin/api.ts`) schaffen Grundlage für Billing/Members/Tasks-Seiten. - DX & Tests: Neue Playwright/E2E-Struktur (docs/testing/e2e.md, `tests/e2e/tenant-onboarding-flow.test.ts`, Utilities), E2E-Tenant-Seeder und zusätzliche Übersetzungen/Factories zur Unterstützung der neuen Flows. - Marketing-Kommunikation: Automatische Kontakt-Bestätigungsmail (`ContactConfirmation` + Blade-Template) implementiert; Guest-PWA unter `/event` erreichbar. - Nebensitzung: Blogsystem gefixt und umfassenden BlogPostSeeder für Beispielinhalte angelegt.
This commit is contained in:
@@ -10,6 +10,7 @@ use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Models\EventCreditsLedger;
|
||||
|
||||
class Tenant extends Model
|
||||
{
|
||||
@@ -24,6 +25,7 @@ class Tenant extends Model
|
||||
'last_activity_at' => 'datetime',
|
||||
'total_revenue' => 'decimal:2',
|
||||
'settings_updated_at' => 'datetime',
|
||||
'subscription_expires_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function events(): HasMany
|
||||
@@ -60,7 +62,7 @@ class Tenant extends Model
|
||||
|
||||
public function canCreateEvent(): bool
|
||||
{
|
||||
$package = $this->activeResellerPackage();
|
||||
$package = $this->activeResellerPackage()->first();
|
||||
if (!$package) {
|
||||
return false;
|
||||
}
|
||||
@@ -70,7 +72,7 @@ class Tenant extends Model
|
||||
|
||||
public function incrementUsedEvents(int $amount = 1): bool
|
||||
{
|
||||
$package = $this->activeResellerPackage();
|
||||
$package = $this->activeResellerPackage()->first();
|
||||
if (!$package) {
|
||||
return false;
|
||||
}
|
||||
@@ -89,10 +91,52 @@ class Tenant extends Model
|
||||
$this->attributes['settings'] = json_encode($value ?? []);
|
||||
}
|
||||
|
||||
public function incrementCredits(int $amount, string $reason = 'manual', ?string $note = null, ?int $purchaseId = null): bool
|
||||
{
|
||||
if ($amount <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$balance = (int) ($this->event_credits_balance ?? 0) + $amount;
|
||||
$this->forceFill(['event_credits_balance' => $balance])->save();
|
||||
|
||||
EventCreditsLedger::create([
|
||||
'tenant_id' => $this->id,
|
||||
'delta' => $amount,
|
||||
'reason' => $reason,
|
||||
'related_purchase_id' => $purchaseId,
|
||||
'note' => $note,
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function decrementCredits(int $amount, string $reason = 'usage', ?string $note = null, ?int $purchaseId = null): bool
|
||||
{
|
||||
$current = (int) ($this->event_credits_balance ?? 0);
|
||||
|
||||
if ($amount <= 0 || $amount > $current) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$balance = $current - $amount;
|
||||
$this->forceFill(['event_credits_balance' => $balance])->save();
|
||||
|
||||
EventCreditsLedger::create([
|
||||
'tenant_id' => $this->id,
|
||||
'delta' => -$amount,
|
||||
'reason' => $reason,
|
||||
'related_purchase_id' => $purchaseId,
|
||||
'note' => $note,
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function activeSubscription(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn () => $this->activeResellerPackage() !== null,
|
||||
get: fn () => $this->activeResellerPackage()->exists(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user