'abo_history.status_paused', self::ACTION_CANCELLED => 'abo_history.status_cancelled', self::ACTION_DEACTIVATED => 'abo_history.status_deactivated', self::ACTION_REACTIVATED => 'abo_history.status_reactivated', ]; public static $actionColors = [ self::ACTION_PAUSED => 'warning', self::ACTION_CANCELLED => 'danger', self::ACTION_DEACTIVATED => 'secondary', self::ACTION_REACTIVATED => 'success', ]; /** * Formular-View → Kanal-Label/Farbe der Item-Historie (gleiche Optik im Protokoll). */ public static $viewChannelMap = [ 'me' => 'user_me', 'ot' => 'user_ot', 'portal' => 'portal', 'admin' => 'admin', ]; protected $fillable = [ 'user_abo_id', 'action', 'view', 'actor_user_id', 'previous_next_date', 'new_next_date', ]; protected $casts = [ 'user_abo_id' => 'int', 'actor_user_id' => 'int', 'previous_next_date' => 'date', 'new_next_date' => 'date', ]; public function user_abo(): BelongsTo { return $this->belongsTo(UserAbo::class); } public function actor(): BelongsTo { return $this->belongsTo(User::class, 'actor_user_id'); } public function getActionBadge(): string { $label = isset(self::$actionLabels[$this->action]) ? __(self::$actionLabels[$this->action]) : $this->action; $color = self::$actionColors[$this->action] ?? 'secondary'; return ''.$label.''; } public function getChannelBadge(): string { $channel = self::$viewChannelMap[$this->view] ?? 'system'; $label = isset(UserAboItemHistory::$channelLabels[$channel]) ? __(UserAboItemHistory::$channelLabels[$channel]) : $channel; $color = UserAboItemHistory::$channelColors[$channel] ?? 'secondary'; return ''.$label.''; } public function getDescription(): string { if ($this->action === self::ACTION_PAUSED && $this->previous_next_date && $this->new_next_date) { return __('abo_history.status_shift', [ 'from' => $this->previous_next_date->format(\Util::formatDateDB()), 'to' => $this->new_next_date->format(\Util::formatDateDB()), ]); } return ''; } public function getFormattedDate(): string { return $this->created_at ? $this->created_at->format(\Util::formatDateDB().' H:i') : ''; } public function getActorName(): string { if (! $this->actor) { return '-'; } $name = trim(($this->actor->account?->first_name ?? '').' '.($this->actor->account?->last_name ?? '')); return $name !== '' ? $name : ($this->actor->email ?? '-'); } }