From bdb62a6ce20ad57c21793d435d21c125dc3910a0 Mon Sep 17 00:00:00 2001 From: Nils Bonorden Date: Fri, 24 Oct 2025 15:05:16 +0200 Subject: [PATCH] Bewerbungsformular update --- .../Admin/BandApplicationAdminController.php | 58 +++++++ .../Admin/BewerbungAdminController.php | 33 ++++ app/Http/Controllers/BewerbungController.php | 89 ++--------- public/js/admin-live-filters.js | 83 ++++++++++ .../views/admin/applications/show.blade.php | 82 ++++++++++ .../views/admin/bewerbungen/index.blade.php | 87 +++++++++++ .../views/admin/bewerbungen/show.blade.php | 121 +++++++++++++++ resources/views/bewerbung/index.blade.php | 74 +++------ resources/views/bewerbung/show.blade.php | 146 +++++++++++++----- .../views/components/status-badge.blade.php | 10 ++ routes/admin_bewerbung.php | 23 +++ routes/bewerbung_routes.php | 8 + routes/web.php | 3 +- 13 files changed, 646 insertions(+), 171 deletions(-) create mode 100644 app/Http/Controllers/Admin/BandApplicationAdminController.php create mode 100644 app/Http/Controllers/Admin/BewerbungAdminController.php create mode 100644 public/js/admin-live-filters.js create mode 100644 resources/views/admin/applications/show.blade.php create mode 100644 resources/views/admin/bewerbungen/index.blade.php create mode 100644 resources/views/admin/bewerbungen/show.blade.php create mode 100644 resources/views/components/status-badge.blade.php create mode 100644 routes/admin_bewerbung.php create mode 100644 routes/bewerbung_routes.php diff --git a/app/Http/Controllers/Admin/BandApplicationAdminController.php b/app/Http/Controllers/Admin/BandApplicationAdminController.php new file mode 100644 index 0000000..cb86949 --- /dev/null +++ b/app/Http/Controllers/Admin/BandApplicationAdminController.php @@ -0,0 +1,58 @@ +load(['band','bewerbung']); + return view('admin.applications.show', compact('application')); + } + + // Status ändern (submitted, in_review, accepted, rejected) + public function updateStatus(Request $request, BandApplication $application) + { + $data = $request->validate([ + 'status' => ['required','in:submitted,in_review,accepted,rejected'], + ]); + + $application->update($data); + + return back()->with('success', 'Status aktualisiert.'); + } + + // Optional: CSV-Export aller Bewerbungen einer Runde + // public function exportCsv(Bewerbung $bewerbung): StreamedResponse + // { + // $filename = 'applications_' . $bewerbung->slug . '.csv'; + // $headers = [ + // 'Content-Type' => 'text/csv', + // 'Content-Disposition' => 'attachment; filename="'.$filename.'"', + // ]; + // $callback = function() use ($bewerbung) { + // $handle = fopen('php://output', 'w'); + // fputcsv($handle, ['ID','Band','Email','Status','Datum','Demo','Nachricht']); + // foreach ($bewerbung->applications()->with('band')->cursor() as $app) { + // fputcsv($handle, [ + // $app->id, + // optional($app->band)->name, + // optional($app->band)->email, + // $app->status, + // $app->created_at, + // $app->demo_link, + // preg_replace("/\r|\n/", " ", (string)$app->message), + // ]); + // } + // fclose($handle); + // }; + // return response()->stream($callback, 200, $headers); + // } +} diff --git a/app/Http/Controllers/Admin/BewerbungAdminController.php b/app/Http/Controllers/Admin/BewerbungAdminController.php new file mode 100644 index 0000000..7fc0a4f --- /dev/null +++ b/app/Http/Controllers/Admin/BewerbungAdminController.php @@ -0,0 +1,33 @@ +withCount('applications') + ->orderByDesc('start_at') + ->orderBy('name') + ->paginate(20); + + return view('admin.bewerbungen.index', compact('bewerbungen')); + } + + // Detailseite einer Runde mit Bewerbungs-Tabelle + public function show(Bewerbung $bewerbung) + { + $applications = $bewerbung->applications() + ->with('band') + ->latest() + ->paginate(25); + + return view('admin.bewerbungen.show', compact('bewerbung','applications')); + } +} diff --git a/app/Http/Controllers/BewerbungController.php b/app/Http/Controllers/BewerbungController.php index 80aa2bf..a049e59 100644 --- a/app/Http/Controllers/BewerbungController.php +++ b/app/Http/Controllers/BewerbungController.php @@ -4,96 +4,25 @@ namespace App\Http\Controllers; use App\Models\Bewerbung; use Illuminate\Http\Request; -use Illuminate\Support\Facades\Storage; class BewerbungController extends Controller { public function index() { - $bewerbungen = Bewerbung::latest()->paginate(15); + $bewerbungen = Bewerbung::query() + ->where('active', true) + ->orderByDesc('start_at') + ->get(); + return view('bewerbung.index', compact('bewerbungen')); } - public function create() - { - return view('bewerbung.create'); - } - - public function store(Request $request) - { - $data = $request->validate([ - 'name' => ['required','string','max:255'], - 'text' => ['required','string','max:5000'], - 'pic' => ['nullable','image','mimes:jpg,jpeg,png','max:4096'], - 'bedingungen' => ['nullable','file','mimetypes:application/pdf','max:8192'], - 'time' => ['nullable'], - 'active' => ['nullable'], - 'start_at' => ['nullable','date'], - 'end_at' => ['nullable','date','after_or_equal:start_at'], - ]); - - if ($request->hasFile('pic')) { - $data['pic_path'] = $request->file('pic')->store('bewerbungen/pics', 'public'); - } - if ($request->hasFile('bedingungen')) { - $data['bedingungen_path'] = $request->file('bedingungen')->store('bewerbungen/bedingungen', 'public'); - } - - $data['active'] = $request->boolean('active'); - $data['time'] = $request->boolean('time'); - - $bewerbung = Bewerbung::create($data); - - return redirect()->route('bewerbungen.show', $bewerbung)->with('success', 'Bewerbung erstellt.'); - } - public function show(Bewerbung $bewerbung) { + if (!$bewerbung->active) abort(404); + if ($bewerbung->start_at && $bewerbung->start_at->isFuture()) abort(404); + if ($bewerbung->end_at && $bewerbung->end_at->isPast()) abort(404); + return view('bewerbung.show', compact('bewerbung')); } - - public function edit(Bewerbung $bewerbung) - { - return view('bewerbung.edit', compact('bewerbung')); - } - - public function update(Request $request, Bewerbung $bewerbung) - { - $data = $request->validate([ - 'name' => ['required','string','max:255'], - 'text' => ['required','string','max:5000'], - 'pic' => ['nullable','image','mimes:jpg,jpeg,png','max:4096'], - 'bedingungen' => ['nullable','file','mimetypes:application/pdf','max:8192'], - 'time' => ['nullable'], - 'active' => ['nullable'], - 'start_at' => ['nullable','date'], - 'end_at' => ['nullable','date','after_or_equal:start_at'], - ]); - - if ($request->hasFile('pic')) { - if ($bewerbung->pic_path) Storage::disk('public')->delete($bewerbung->pic_path); - $data['pic_path'] = $request->file('pic')->store('bewerbungen/pics', 'public'); - } - - if ($request->hasFile('bedingungen')) { - if ($bewerbung->bedingungen_path) Storage::disk('public')->delete($bewerbung->bedingungen_path); - $data['bedingungen_path'] = $request->file('bedingungen')->store('bewerbungen/bedingungen', 'public'); - } - - $data['active'] = $request->boolean('active'); - $data['time'] = $request->boolean('time'); - - $bewerbung->update($data); - - return redirect()->route('bewerbungen.show', $bewerbung)->with('success', 'Bewerbung aktualisiert.'); - } - - public function destroy(Bewerbung $bewerbung) - { - if ($bewerbung->pic_path) Storage::disk('public')->delete($bewerbung->pic_path); - if ($bewerbung->bedingungen_path) Storage::disk('public')->delete($bewerbung->bedingungen_path); - $bewerbung->delete(); - - return redirect()->route('bewerbungen.index')->with('success', 'Bewerbung gelöscht.'); - } } diff --git a/public/js/admin-live-filters.js b/public/js/admin-live-filters.js new file mode 100644 index 0000000..6196485 --- /dev/null +++ b/public/js/admin-live-filters.js @@ -0,0 +1,83 @@ +/*! admin-live-filters.js — Vue 3 (CDN) */ +(function() { + // Debounce helper + function debounce(fn, delay) { + let t; return function(...args) { + clearTimeout(t); t = setTimeout(() => fn.apply(this, args), delay); + }; + } + + // Mount for rounds list (index) + const elIndex = document.getElementById('admin-bewerbungen-index'); + if (elIndex) { + const dataEl = document.getElementById('admin-bewerbungen-index-data'); + const raw = dataEl ? JSON.parse(dataEl.textContent) : { items: [] }; + const { createApp, computed, ref, watch } = Vue; + + createApp({ + setup() { + const q = ref(''); + const activeOnly = ref(false); + const items = ref(raw.items || []); + + const filtered = computed(() => { + const needle = q.value.trim().toLowerCase(); + return items.value.filter(it => { + const text = ((it.name || '') + ' ' + (it.period || '')).toLowerCase(); + const okText = !needle || text.includes(needle); + const okActive = !activeOnly.value || !!it.active; + return okText && okActive; + }); + }); + + const clear = () => { q.value = ''; activeOnly.value = false; }; + + return { q, activeOnly, items, filtered, clear }; + } + }).mount('#admin-bewerbungen-index'); + } + + // Mount for applications table (show) + const elShow = document.getElementById('admin-bewerbungen-show'); + if (elShow) { + const dataEl = document.getElementById('admin-bewerbungen-show-data'); + const raw = dataEl ? JSON.parse(dataEl.textContent) : { items: [] }; + const { createApp, computed, ref } = Vue; + + createApp({ + setup() { + const q = ref(''); + const status = ref(''); + const dateFrom = ref(''); + const dateTo = ref(''); + const items = ref(raw.items || []); + + const filtered = computed(() => { + const needle = q.value.trim().toLowerCase(); + const from = dateFrom.value ? new Date(dateFrom.value + 'T00:00:00') : null; + const to = dateTo.value ? new Date(dateTo.value + 'T23:59:59') : null; + + return items.value.filter(it => { + // text match + const text = ((it.band || '') + ' ' + (it.email || '')).toLowerCase(); + const okText = !needle || text.includes(needle); + + // status match + const okStatus = !status.value || it.status === status.value; + + // date range match (created_at ISO string expected) + const t = it.created_at ? new Date(it.created_at) : null; + const okFrom = !from || (t && t >= from); + const okTo = !to || (t && t <= to); + + return okText && okStatus && okFrom && okTo; + }); + }); + + const reset = () => { q.value = ''; status.value=''; dateFrom.value=''; dateTo.value=''; }; + + return { q, status, dateFrom, dateTo, items, filtered, reset }; + } + }).mount('#admin-bewerbungen-show'); + } +})(); diff --git a/resources/views/admin/applications/show.blade.php b/resources/views/admin/applications/show.blade.php new file mode 100644 index 0000000..7a94f3b --- /dev/null +++ b/resources/views/admin/applications/show.blade.php @@ -0,0 +1,82 @@ +@extends('template') +@section('title','Admin · Bewerbung #'.$application->id) +@section('content') +@if(session('success')) +
{{ session('success') }}
+@endif + +
+

Bewerbung #{{ $application->id }}

+ Zurück zur Runde +
+ +
+
+
+
+
Band
+
Name: {{ optional($application->band)->name }}
+
E-Mail: {{ optional($application->band)->email }}
+ @if(optional($application->band)->phone) +
Telefon: {{ $application->band->phone }}
+ @endif +
+ @if(optional($application->band)->website)Website@endif + @if(optional($application->band)->spotify)Spotify@endif + @if(optional($application->band)->instagram)Instagram@endif + @if(optional($application->band)->youtube)YouTube@endif + @if(optional($application->band)->tech_rider_path)Tech Rider@endif + @if(optional($application->band)->stage_plan_path)Stage Plan@endif +
+ @if(optional($application->band)->about) +
+ Über die Band +

{{ $application->band->about }}

+
+ @endif +
+
+
+
+
+
+
Bewerbung
+
Runde: {{ $application->bewerbung->name }}
+
Eingang: {{ $application->created_at->format('d.m.Y H:i') }}
+
Status: @include('components.status-badge', ['status' => $application->status])
+ +
+ @csrf + @method('PATCH') + + +
+ + @if($errors->any()) +
+
    + @foreach($errors->all() as $e) +
  • {{ $e }}
  • + @endforeach +
+
+ @endif +
+
+
+
+ +
+
+
Nachricht
+

{{ $application->message }}

+ @if($application->demo_link) +

Demo: {{ $application->demo_link }}

+ @endif +
+
+@endsection diff --git a/resources/views/admin/bewerbungen/index.blade.php b/resources/views/admin/bewerbungen/index.blade.php new file mode 100644 index 0000000..81e35e5 --- /dev/null +++ b/resources/views/admin/bewerbungen/index.blade.php @@ -0,0 +1,87 @@ +@extends('template') +@section('title','Admin · Bewerbungsrunden') + +@section('content') +
+

Bewerbungsrunden

+
+ +{{-- Live-Filter UI (Vue) --}} +
+
+
+
+ +
+
+
+ + +
+
+
+ +
+
+
+
+ +
+ + + + + + + + + + + + + + +
NameZeitraumAktivBewerbungen
Keine Treffer.
+
+ +{{-- Original Laravel-Pagination ist ausgeblendet, da die Liste clientseitig gefiltert wird. --}} +{{-- {{ $bewerbungen->links() }} --}} + +{{-- Serverdaten für Vue als JSON bereitstellen --}} + +@endsection + +@push('scripts') + {{-- Vue 3 CDN + App --}} + + +@endpush diff --git a/resources/views/admin/bewerbungen/show.blade.php b/resources/views/admin/bewerbungen/show.blade.php new file mode 100644 index 0000000..35ec986 --- /dev/null +++ b/resources/views/admin/bewerbungen/show.blade.php @@ -0,0 +1,121 @@ +@extends('template') +@section('title','Admin · Runde: ' . $bewerbung->name) + +@section('content') +
+
+

Runde: {{ $bewerbung->name }}

+ + @if($bewerbung->start_at) Start: {{ $bewerbung->start_at->format('d.m.Y') }} @endif + @if($bewerbung->end_at) · Ende: {{ $bewerbung->end_at->format('d.m.Y') }} @endif + · Status: @if($bewerbung->active)aktiv@elseinaktiv@endif + +
+
+ Zurück +
+
+ +{{-- Live-Filter UI --}} +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+ + + + + + + + + + + + + + + +
#BandE-MailStatusDatum
Keine Treffer.
+
+ +{{-- Serverseitige Pagination ausgeblendet, da wir clientseitig filtern. --}} +{{-- {{ $applications->links() }} --}} + +{{-- Serverdaten als JSON --}} + +@endsection + +@push('scripts') + + +@endpush diff --git a/resources/views/bewerbung/index.blade.php b/resources/views/bewerbung/index.blade.php index 8ea02d0..0cd7bd6 100644 --- a/resources/views/bewerbung/index.blade.php +++ b/resources/views/bewerbung/index.blade.php @@ -1,59 +1,25 @@ @extends('template') - @section('title', 'Bewerbungen') + @section('content') -
-
-

Bewerbungen

- Neu +

Aktive Bewerbungen

+ +@if($bewerbungen->isEmpty()) +
Derzeit sind keine aktiven Bewerbungen sichtbar.
+@else + - - @if(session('success')) -
{{ session('success') }}
- @endif - - - - - - - - - - - - - - @forelse($bewerbungen as $b) - - - - - - - - - @empty - - @endforelse - -
#NameAktivZeitraumErstelltAktionen
{{ $b->id }}{{ $b->name }} - - {{ $b->active ? 'Ja' : 'Nein' }} - - - @if($b->start_at) {{ $b->start_at->format('d.m.Y H:i') }} @endif - @if($b->end_at) – {{ $b->end_at->format('d.m.Y H:i') }} @endif - {{ optional($b->created_at)->format('d.m.Y H:i') }} - Anzeigen - Bearbeiten -
- @csrf - @method('DELETE') - -
-
Keine Bewerbungen vorhanden.
- - {{ $bewerbungen->links() }} -
+@endif @endsection diff --git a/resources/views/bewerbung/show.blade.php b/resources/views/bewerbung/show.blade.php index 9c26988..fb88e86 100644 --- a/resources/views/bewerbung/show.blade.php +++ b/resources/views/bewerbung/show.blade.php @@ -1,44 +1,118 @@ @extends('template') +@section('title', $bewerbung->name) -@section('title', 'Bewerbung anzeigen') @section('content') -
- @if(session('success')) -
{{ session('success') }}
- @endif +@if(session('success')) +
{{ session('success') }}
+@endif -
-

{{ $bewerbung->name }}

-
- Bearbeiten - Zur Liste +
+
+

{{ $bewerbung->name }}

+ + @if($bewerbung->pic_path ?? false) + {{ $bewerbung->name }} + @endif + +
{{ $bewerbung->text }}
+ + @if($bewerbung->bedingungen_path ?? false) +

+ + Bewerbungsbedingungen (PDF) + +

+ @endif + + @if ($errors->any()) +
+ Bitte prüfen: +
    + @foreach ($errors->all() as $e) +
  • {{ $e }}
  • + @endforeach +
+
+ @endif + +
+ @csrf +

Band

+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+

Bewerbung

+
+ + +
+
+ + +
+
+ + +
+ +
+
+
+
+
+
Eckdaten
+
    + @if($bewerbung->start_at)
  • Start: {{ $bewerbung->start_at->format('d.m.Y') }}
  • @endif + @if($bewerbung->end_at)
  • Ende: {{ $bewerbung->end_at->format('d.m.Y') }}
  • @endif +
  • Status: {{ $bewerbung->active ? 'Aktiv' : 'Inaktiv' }}
  • +
+
- -

Aktiv: {{ $bewerbung->active ? 'Ja' : 'Nein' }}

-

Zeitraum: - @if($bewerbung->start_at) {{ $bewerbung->start_at->format('d.m.Y H:i') }} @endif - @if($bewerbung->end_at) – {{ $bewerbung->end_at->format('d.m.Y H:i') }} @endif -

- -
- Text: -
{{ $bewerbung->text }}
-
- - @if($bewerbung->pic_path) -

Bild:
-

- @endif - - @if($bewerbung->bedingungen_path) -

Bewerbungsbedingungen: PDF öffnen

- @endif - -
- @csrf - @method('DELETE') - -
@endsection diff --git a/resources/views/components/status-badge.blade.php b/resources/views/components/status-badge.blade.php new file mode 100644 index 0000000..81e1117 --- /dev/null +++ b/resources/views/components/status-badge.blade.php @@ -0,0 +1,10 @@ +@php + $map = [ + 'submitted' => ['label' => 'Eingereicht', 'class' => 'text-bg-secondary'], + 'in_review' => ['label' => 'In Prüfung', 'class' => 'text-bg-warning'], + 'accepted' => ['label' => 'Zugesagt', 'class' => 'text-bg-success'], + 'rejected' => ['label' => 'Abgesagt', 'class' => 'text-bg-danger'], + ]; + $cfg = $map[$status] ?? ['label' => $status, 'class' => 'text-bg-light']; +@endphp +{{ $cfg['label'] }} diff --git a/routes/admin_bewerbung.php b/routes/admin_bewerbung.php new file mode 100644 index 0000000..4e5cc0a --- /dev/null +++ b/routes/admin_bewerbung.php @@ -0,0 +1,23 @@ +prefix('admin/bewerbungen') + ->name('admin.bewerbungen.') + ->group(function () { + Route::get('/', [BewerbungAdminController::class, 'index'])->name('index'); + Route::get('/{bewerbung:slug}', [BewerbungAdminController::class, 'show'])->name('show'); + }); + +Route::middleware(['web']) // ggf. ['web','auth'] + ->prefix('admin/applications') + ->name('admin.applications.') + ->group(function () { + Route::get('/{application}', [BandApplicationAdminController::class, 'show'])->name('show'); + Route::patch('/{application}/status', [BandApplicationAdminController::class, 'updateStatus'])->name('status'); + // Optional: CSV-Export aller Bewerbungen einer Runde: + // Route::get('/export/{bewerbung:slug}', [BandApplicationAdminController::class, 'exportCsv'])->name('export'); + }); diff --git a/routes/bewerbung_routes.php b/routes/bewerbung_routes.php new file mode 100644 index 0000000..718005d --- /dev/null +++ b/routes/bewerbung_routes.php @@ -0,0 +1,8 @@ +name('bewerbung.index'); +Route::get('/bewerbung/{bewerbung:slug}', [BewerbungController::class, 'show'])->name('bewerbung.show'); +Route::post('/bewerbung/{bewerbung:slug}/apply', [BandApplicationController::class, 'store'])->name('band.apply'); diff --git a/routes/web.php b/routes/web.php index c6d8228..7a0142e 100644 --- a/routes/web.php +++ b/routes/web.php @@ -5,7 +5,8 @@ use Illuminate\Support\Facades\Route; use App\Http\Controllers\BandsController; use App\Http\Controllers\BewerbungController; - +require __DIR__ . '/admin_bewerbung.php'; +require __DIR__ . '/bewerbung_routes.php'; Route::get('/', function () { return view('wartung');