Enth\u00e4lt gemischt: Laravel-10-Upgrade + Phase 1 (Contacts-Modul, Duplicats-Commands, Soft-Delete+Merge-Fields) + Phase 2 Code-Umstellungen (inquiry_id, $table='contacts'/'inquiries') + Offers-Modul (Migrationen, Models, offer_id in Booking, offer-Disk in filesystems.php). Phase 2 + Offers werden im folgenden Commit nach dev/backups/phase2-offers-2026-04-17/ verschoben, damit der Workspace auf Phase-1-only (= Test-System-Stand) reduziert ist und direkt auf Live deploybar wird. Tarball-Backup zus\u00e4tzlich unter: ../backups-safety/workspace-pre-phase1-rollback-2026-04-17.tar.gz Made-with: Cursor
99 lines
3.2 KiB
PHP
99 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* Class NewsletterLog
|
|
*
|
|
* @property int $id
|
|
* @property int $newsletter_contact_id
|
|
* @property string $action
|
|
* @property string|null $description
|
|
* @property array|null $metadata
|
|
* @property int|null $user_id
|
|
* @property Carbon $created_at
|
|
* @property Carbon $updated_at
|
|
* @property-read NewsletterContact $newsletter_contact
|
|
* @property-read SfGuardUser|null $user
|
|
* @package App\Models
|
|
* @property-read mixed $action_label
|
|
* @method static \Illuminate\Database\Eloquent\Builder|NewsletterLog newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|NewsletterLog newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|NewsletterLog query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|NewsletterLog whereAction($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|NewsletterLog whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|NewsletterLog whereDescription($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|NewsletterLog whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|NewsletterLog whereMetadata($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|NewsletterLog whereNewsletterContactId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|NewsletterLog whereUpdatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|NewsletterLog whereUserId($value)
|
|
* @mixin \Eloquent
|
|
*/
|
|
class NewsletterLog extends Model
|
|
{
|
|
protected $connection = 'mysql';
|
|
|
|
protected $table = 'newsletter_logs';
|
|
|
|
protected $casts = [
|
|
'newsletter_contact_id' => 'int',
|
|
'user_id' => 'int',
|
|
'metadata' => 'array',
|
|
];
|
|
|
|
protected $fillable = [
|
|
'newsletter_contact_id',
|
|
'action',
|
|
'description',
|
|
'metadata',
|
|
'user_id',
|
|
];
|
|
|
|
// Aktions-Konstanten
|
|
const ACTION_SUBSCRIBED = 'subscribed';
|
|
const ACTION_UNSUBSCRIBED = 'unsubscribed';
|
|
const ACTION_BOOKING_ADDED = 'booking_added';
|
|
const ACTION_STATUS_CHANGED = 'status_changed';
|
|
const ACTION_GROUP_CHANGED = 'group_changed';
|
|
const ACTION_EMAIL_SENT = 'email_sent';
|
|
const ACTION_BOUNCED = 'bounced';
|
|
|
|
public static $actionLabels = [
|
|
self::ACTION_SUBSCRIBED => 'Angemeldet',
|
|
self::ACTION_UNSUBSCRIBED => 'Abgemeldet',
|
|
self::ACTION_BOOKING_ADDED => 'Buchung hinzugefügt',
|
|
self::ACTION_STATUS_CHANGED => 'Status geändert',
|
|
self::ACTION_GROUP_CHANGED => 'Gruppe geändert',
|
|
self::ACTION_EMAIL_SENT => 'E-Mail versendet',
|
|
self::ACTION_BOUNCED => 'Bounced',
|
|
];
|
|
|
|
/**
|
|
* Beziehung zum Newsletter-Kontakt
|
|
*/
|
|
public function newsletter_contact()
|
|
{
|
|
return $this->belongsTo(NewsletterContact::class, 'newsletter_contact_id');
|
|
}
|
|
|
|
/**
|
|
* Beziehung zum Admin-User
|
|
*/
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(SfGuardUser::class, 'user_id');
|
|
}
|
|
|
|
/**
|
|
* Action-Label
|
|
*/
|
|
public function getActionLabelAttribute()
|
|
{
|
|
return self::$actionLabels[$this->action] ?? $this->action;
|
|
}
|
|
}
|
|
|