feat: extend event toolkit and polish guest pwa

This commit is contained in:
Codex Agent
2025-10-28 18:28:22 +01:00
parent f29067f570
commit a7bbf230fd
45 changed files with 3809 additions and 351 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Models;
use Carbon\CarbonInterface;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -43,6 +44,10 @@ class TenantPackage extends Model
public function isActive(): bool
{
if ($this->package && $this->package->isEndcustomer()) {
return (bool) $this->active;
}
return $this->active && (! $this->expires_at || $this->expires_at->isFuture());
}
@@ -76,23 +81,43 @@ class TenantPackage extends Model
{
parent::boot();
static::creating(function ($tenantPackage) {
static::creating(function (self $tenantPackage) {
if (! $tenantPackage->purchased_at) {
$tenantPackage->purchased_at = now();
}
if (! $tenantPackage->expires_at && $tenantPackage->package) {
$tenantPackage->expires_at = now()->addYear(); // Standard für Reseller
$package = $tenantPackage->package;
if ($package && $package->isReseller()) {
if (! $tenantPackage->expires_at) {
$tenantPackage->expires_at = now()->addYear();
}
} else {
$tenantPackage->expires_at = now()->addCentury();
}
if ($tenantPackage->active === null) {
$tenantPackage->active = true;
}
$tenantPackage->active = true;
});
static::updating(function ($tenantPackage) {
if (
$tenantPackage->isDirty('expires_at')
&& $tenantPackage->expires_at instanceof \Carbon\CarbonInterface
&& $tenantPackage->expires_at->isPast()
) {
$tenantPackage->active = false;
static::updating(function (self $tenantPackage) {
$package = $tenantPackage->package;
if ($package && $package->isReseller()) {
if (
$tenantPackage->isDirty('expires_at')
&& $tenantPackage->expires_at instanceof CarbonInterface
&& $tenantPackage->expires_at->isPast()
) {
$tenantPackage->active = false;
}
return;
}
if ($tenantPackage->isDirty('expires_at')) {
$tenantPackage->expires_at = now()->addCentury();
}
});
}