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')) +
{{ $application->band->about }}
+{{ $application->message }}
+ @if($application->demo_link) + + @endif +| Name | +Zeitraum | +Aktiv | +Bewerbungen | ++ |
|---|---|---|---|---|
| @{{ b.name }} | +@{{ b.period }} | ++ + @{{ b.active ? 'aktiv' : 'inaktiv' }} + + | +@{{ b.applications_count }} | ++ Öffnen + | +
| Keine Treffer. | ||||
| # | +Band | +Status | +Datum | ++ | |
|---|---|---|---|---|---|
| @{{ app.id }} | +@{{ app.band }} | +@{{ app.email }} | ++ + @{{ app.status_label }} + + | +@{{ app.created_label }} | ++ Öffnen + | +
| Keine Treffer. | |||||
| # | -Name | -Aktiv | -Zeitraum | -Erstellt | -Aktionen | -
|---|---|---|---|---|---|
| {{ $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 - - | -
| Keine Bewerbungen vorhanden. | |||||
+ + Bewerbungsbedingungen (PDF) + +
+ @endif + + @if ($errors->any()) +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 -
- -Bild:
-
Bewerbungsbedingungen: PDF öffnen
- @endif - -