added missing translations
This commit is contained in:
65
app/Filament/Resources/TenantFeedbackResource.php
Normal file
65
app/Filament/Resources/TenantFeedbackResource.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\TenantFeedbackResource\Pages\ListTenantFeedback;
|
||||
use App\Filament\Resources\TenantFeedbackResource\Pages\ViewTenantFeedback;
|
||||
use App\Filament\Resources\TenantFeedbackResource\Schemas\TenantFeedbackForm;
|
||||
use App\Filament\Resources\TenantFeedbackResource\Schemas\TenantFeedbackInfolist;
|
||||
use App\Filament\Resources\TenantFeedbackResource\Tables\TenantFeedbackTable;
|
||||
use App\Models\TenantFeedback;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
use UnitEnum;
|
||||
|
||||
class TenantFeedbackResource extends Resource
|
||||
{
|
||||
protected static ?string $model = TenantFeedback::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedChatBubbleBottomCenterText;
|
||||
|
||||
protected static UnitEnum|string|null $navigationGroup = null;
|
||||
|
||||
protected static ?int $navigationSort = 120;
|
||||
|
||||
public static function canCreate(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return TenantFeedbackForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return TenantFeedbackInfolist::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return TenantFeedbackTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getNavigationGroup(): UnitEnum|string|null
|
||||
{
|
||||
return __('Feedback & Support');
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListTenantFeedback::route('/'),
|
||||
'view' => ViewTenantFeedback::route('/{record}'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TenantFeedbackResource\Pages;
|
||||
|
||||
use App\Filament\Resources\TenantFeedbackResource;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListTenantFeedback extends ListRecords
|
||||
{
|
||||
protected static string $resource = TenantFeedbackResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TenantFeedbackResource\Pages;
|
||||
|
||||
use App\Filament\Resources\TenantFeedbackResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewTenantFeedback extends ViewRecord
|
||||
{
|
||||
protected static string $resource = TenantFeedbackResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TenantFeedbackResource\Schemas;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class TenantFeedbackForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TenantFeedbackResource\Schemas;
|
||||
|
||||
use Filament\Infolists\Components\KeyValueEntry;
|
||||
use Filament\Infolists\Components\Section;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Schema;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class TenantFeedbackInfolist
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Section::make(__('Überblick'))
|
||||
->columns(3)
|
||||
->schema([
|
||||
TextEntry::make('tenant.name')->label(__('Tenant'))->placeholder('—'),
|
||||
TextEntry::make('event.name')->label(__('Event'))->placeholder('—'),
|
||||
TextEntry::make('category')
|
||||
->label(__('Kategorie'))
|
||||
->badge()
|
||||
->formatStateUsing(fn ($state) => $state ? Str::headline($state) : '—'),
|
||||
TextEntry::make('sentiment')
|
||||
->label(__('Stimmung'))
|
||||
->badge()
|
||||
->color(fn (?string $state) => match ($state) {
|
||||
'positive' => 'success',
|
||||
'neutral' => 'warning',
|
||||
'negative' => 'danger',
|
||||
default => 'gray',
|
||||
})
|
||||
->formatStateUsing(fn (?string $state) => $state ? Str::headline($state) : '—'),
|
||||
TextEntry::make('rating')
|
||||
->label(__('Rating'))
|
||||
->formatStateUsing(fn (?int $state) => $state ? sprintf('%d/5', $state) : '—'),
|
||||
TextEntry::make('created_at')
|
||||
->label(__('Eingegangen'))
|
||||
->since(),
|
||||
]),
|
||||
Section::make(__('Inhalt'))
|
||||
->columns(1)
|
||||
->schema([
|
||||
TextEntry::make('title')
|
||||
->label(__('Betreff'))
|
||||
->placeholder('—'),
|
||||
TextEntry::make('message')
|
||||
->label(__('Nachricht'))
|
||||
->markdown()
|
||||
->placeholder('—'),
|
||||
]),
|
||||
Section::make(__('Metadaten'))
|
||||
->schema([
|
||||
KeyValueEntry::make('metadata')
|
||||
->label(__('Metadata'))
|
||||
->columnSpanFull(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TenantFeedbackResource\Tables;
|
||||
|
||||
use App\Models\TenantFeedback;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class TenantFeedbackTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultSort('created_at', 'desc')
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label(__('Eingegangen'))
|
||||
->since()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('tenant.name')
|
||||
->label(__('Tenant'))
|
||||
->searchable()
|
||||
->limit(30),
|
||||
Tables\Columns\TextColumn::make('event.name')
|
||||
->label(__('Event'))
|
||||
->limit(30)
|
||||
->toggleable(),
|
||||
Tables\Columns\TextColumn::make('category')
|
||||
->label(__('Kategorie'))
|
||||
->badge()
|
||||
->formatStateUsing(fn (string $state) => Str::headline($state))
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('sentiment')
|
||||
->label(__('Stimmung'))
|
||||
->badge()
|
||||
->color(fn (?string $state) => match ($state) {
|
||||
'positive' => 'success',
|
||||
'neutral' => 'warning',
|
||||
'negative' => 'danger',
|
||||
default => 'gray',
|
||||
})
|
||||
->formatStateUsing(fn (?string $state) => $state ? Str::headline($state) : '—')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('rating')
|
||||
->label(__('Rating'))
|
||||
->formatStateUsing(fn (?int $state) => $state ? sprintf('%d/5', $state) : '—')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('message')
|
||||
->label(__('Nachricht'))
|
||||
->limit(60)
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('sentiment')
|
||||
->label(__('Stimmung'))
|
||||
->options([
|
||||
'positive' => __('Positiv'),
|
||||
'neutral' => __('Neutral'),
|
||||
'negative' => __('Negativ'),
|
||||
]),
|
||||
SelectFilter::make('category')
|
||||
->label(__('Kategorie'))
|
||||
->options(fn () => TenantFeedback::query()
|
||||
->whereNotNull('category')
|
||||
->orderBy('category')
|
||||
->pluck('category', 'category')
|
||||
->toArray()),
|
||||
])
|
||||
->recordActions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
])
|
||||
->bulkActions([]);
|
||||
}
|
||||
}
|
||||
@@ -1230,6 +1230,7 @@ class EventPublicController extends BaseController
|
||||
|
||||
$branding = $this->buildGalleryBranding($event);
|
||||
$expiresAt = optional($event->eventPackage)->gallery_expires_at;
|
||||
$settings = is_array($event->settings) ? $event->settings : [];
|
||||
|
||||
return response()->json([
|
||||
'event' => [
|
||||
@@ -1238,6 +1239,8 @@ class EventPublicController extends BaseController
|
||||
'slug' => $event->slug,
|
||||
'description' => $this->translateLocalized($event->description, $locale, ''),
|
||||
'gallery_expires_at' => $expiresAt?->toIso8601String(),
|
||||
'guest_downloads_enabled' => (bool) ($settings['guest_downloads_enabled'] ?? true),
|
||||
'guest_sharing_enabled' => (bool) ($settings['guest_sharing_enabled'] ?? true),
|
||||
],
|
||||
'branding' => $branding,
|
||||
]);
|
||||
|
||||
@@ -5,9 +5,12 @@ namespace App\Http\Controllers\Api\Tenant;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Event;
|
||||
use App\Models\TenantFeedback;
|
||||
use App\Models\User;
|
||||
use App\Notifications\TenantFeedbackSubmitted;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
|
||||
class TenantFeedbackController extends Controller
|
||||
{
|
||||
@@ -52,6 +55,15 @@ class TenantFeedbackController extends Controller
|
||||
'metadata' => $validated['metadata'] ?? null,
|
||||
]);
|
||||
|
||||
$recipients = User::query()
|
||||
->where('role', 'super_admin')
|
||||
->whereNotNull('email')
|
||||
->get();
|
||||
|
||||
if ($recipients->isNotEmpty()) {
|
||||
Notification::send($recipients, new TenantFeedbackSubmitted($feedback));
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Feedback gespeichert',
|
||||
'data' => [
|
||||
|
||||
@@ -8,6 +8,8 @@ use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Http\Resources\MissingValue;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
use function app;
|
||||
|
||||
class EventResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
@@ -54,6 +56,9 @@ class EventResource extends JsonResource
|
||||
'engagement_mode' => $settings['engagement_mode'] ?? 'tasks',
|
||||
'settings' => $settings,
|
||||
'event_type_id' => $this->event_type_id,
|
||||
'event_type' => $this->whenLoaded('eventType', function () {
|
||||
return new EventTypeResource($this->eventType);
|
||||
}),
|
||||
'created_at' => $this->created_at?->toISOString(),
|
||||
'updated_at' => $this->updated_at?->toISOString(),
|
||||
'photo_count' => (int) ($this->photos_count ?? 0),
|
||||
|
||||
84
app/Notifications/TenantFeedbackSubmitted.php
Normal file
84
app/Notifications/TenantFeedbackSubmitted.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Filament\Resources\TenantFeedbackResource;
|
||||
use App\Models\TenantFeedback;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class TenantFeedbackSubmitted extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(protected TenantFeedback $feedback)
|
||||
{
|
||||
$this->feedback->loadMissing('tenant', 'event');
|
||||
}
|
||||
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
public function toMail(object $notifiable): MailMessage
|
||||
{
|
||||
$tenantName = $this->resolveName($this->feedback->tenant?->name) ?: __('emails.tenant_feedback.unknown_tenant');
|
||||
$eventName = $this->resolveName($this->feedback->event?->name) ?: ($this->feedback->metadata['event_name'] ?? null);
|
||||
$sentiment = $this->feedback->sentiment ? Str::headline($this->feedback->sentiment) : __('emails.tenant_feedback.unknown');
|
||||
$rating = $this->feedback->rating ? sprintf('%d/5', $this->feedback->rating) : null;
|
||||
|
||||
$subject = __('emails.tenant_feedback.subject', [
|
||||
'tenant' => $tenantName,
|
||||
'sentiment' => $sentiment,
|
||||
]);
|
||||
|
||||
$mail = (new MailMessage())
|
||||
->subject($subject)
|
||||
->line(__('emails.tenant_feedback.tenant', ['tenant' => $tenantName]))
|
||||
->line(__('emails.tenant_feedback.category', ['category' => $this->feedback->category ? Str::headline($this->feedback->category) : '—']))
|
||||
->line(__('emails.tenant_feedback.sentiment', ['sentiment' => $sentiment]));
|
||||
|
||||
if ($eventName) {
|
||||
$mail->line(__('emails.tenant_feedback.event', ['event' => $eventName]));
|
||||
}
|
||||
|
||||
if ($rating) {
|
||||
$mail->line(__('emails.tenant_feedback.rating', ['rating' => $rating]));
|
||||
}
|
||||
|
||||
if ($this->feedback->title) {
|
||||
$mail->line(__('emails.tenant_feedback.title', ['subject' => $this->feedback->title]));
|
||||
}
|
||||
|
||||
if ($this->feedback->message) {
|
||||
$mail->line(__('emails.tenant_feedback.message'))->line($this->feedback->message);
|
||||
}
|
||||
|
||||
$url = TenantFeedbackResource::getUrl('view', ['record' => $this->feedback], panel: 'superadmin');
|
||||
|
||||
if ($url) {
|
||||
$mail->action(__('emails.tenant_feedback.open'), $url);
|
||||
}
|
||||
|
||||
$mail->line(__('emails.tenant_feedback.received_at', ['date' => $this->feedback->created_at?->toDayDateTimeString()]));
|
||||
|
||||
return $mail;
|
||||
}
|
||||
|
||||
protected function resolveName(mixed $name): ?string
|
||||
{
|
||||
if (is_string($name) && $name !== '') {
|
||||
return $name;
|
||||
}
|
||||
|
||||
if (is_array($name)) {
|
||||
return $name['de'] ?? $name['en'] ?? reset($name) ?: null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user