feat: extend event toolkit and polish guest pwa
This commit is contained in:
38
app/Models/InviteLayout.php
Normal file
38
app/Models/InviteLayout.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class InviteLayout extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'slug',
|
||||
'name',
|
||||
'subtitle',
|
||||
'description',
|
||||
'paper',
|
||||
'orientation',
|
||||
'preview',
|
||||
'layout_options',
|
||||
'instructions',
|
||||
'is_active',
|
||||
'created_by',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'preview' => 'array',
|
||||
'layout_options' => 'array',
|
||||
'instructions' => 'array',
|
||||
'is_active' => 'bool',
|
||||
];
|
||||
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
}
|
||||
30
app/Models/TenantFeedback.php
Normal file
30
app/Models/TenantFeedback.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class TenantFeedback extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'tenant_feedback';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
protected $casts = [
|
||||
'metadata' => 'array',
|
||||
];
|
||||
|
||||
public function tenant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Tenant::class);
|
||||
}
|
||||
|
||||
public function event(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Event::class);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user