Fixes mit chtgpt

This commit is contained in:
Nils Bonorden committed 2025-10-17 10:00:01 +02:00
1 parent fcae679714
commit 3db040e243
4 files changed
+112 -13

No files matched your search

@@ -0,0 +1,82 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use App\Models\Bewerbung;
class BewerbungController extends Controller
{
public function index()
{
$bewerbungen = Bewerbung::orderByDesc('created_at')->paginate(15);
return view('bewerbung_index', compact('bewerbungen'));
}
public function create()
{
return view('bewerbungc');
}
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'],
'active' => ['nullable','boolean'],
'time' => ['nullable','boolean'],
'sdate' => ['nullable','date'],
'edate' => ['nullable','date','after_or_equal:sdate'],
'stime' => ['nullable','date_format:H:i'],
'etime' => ['nullable','date_format:H:i'],
]);
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'] = (bool) $request->input('active', false);
$data['time'] = (bool) $request->input('time', false);
// Build datetime columns if provided
$start_at = null;
$end_at = null;
if ($request->filled('sdate')) {
$start_at = $request->input('sdate');
if ($request->filled('stime')) {
$start_at .= ' '.$request->input('stime').':00';
} else {
$start_at .= ' 00:00:00';
}
}
if ($request->filled('edate')) {
$end_at = $request->input('edate');
if ($request->filled('etime')) {
$end_at .= ' '.$request->input('etime').':00';
} else {
$end_at .= ' 23:59:59';
}
}
$bewerbung = Bewerbung::create([
'name' => $data['name'],
'text' => $data['text'],
'pic_path' => $data['pic_path'] ?? null,
'bedingungen_path' => $data['bedingungen_path'] ?? null,
'active' => $data['active'],
'time' => $data['time'],
'start_at' => $start_at,
'end_at' => $end_at,
]);
return redirect()->route('bewerbung.index')->with('success', 'Bewerbung gespeichert.');
}
}
+25
View File
@@ -0,0 +1,25 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Bewerbung extends Model
{
use HasFactory;
protected $table = 'bewerbungen';
protected $fillable = [
'name','text','pic_path','bedingungen_path','active','time',
'start_at','end_at'
];
protected $casts = [
'active' => 'boolean',
'time' => 'boolean',
'start_at' => 'datetime',
'end_at' => 'datetime',
];
}
+1 -1
View File
@@ -7,7 +7,7 @@
<div class="col-md-12"><div class="col-md-3">&nbsp;</div><div class="col-md-4 col-lg-4">
<p>Muss noch variabel gefüllt werden</p>
<p><a href="#" target="_blank">Bewerbungsbedingungen</a></p>
<form method="POST" action="">
<form method="POST" action="{{ route('bewerbung.store') }}" enctype="multipart/form-data">@csrf
<label for="bname">Bandname*</label>
<input type="text" name="bname" id="bname" class="text" placeholder="Bandname" value="" required>
<label for="musik">Musikrichtung</label>
+4 -12
View File
@@ -3,7 +3,7 @@
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\BandsController;
use App\Http\Controllers\berwerbung;
use App\Http\Controllers\BewerbungController;
Route::get('/', function () {
return view('wartung');
@@ -24,14 +24,6 @@ Route::get('kontakt', function() {
return 'Nils Bonorden';
});
Route::get('bewerbung', function() {
return view('bewerbung');
});
Route::get('bewerbung/create', function() {
return view('bewerbungc');
});
Route::post('/bewerbung', [bewerbung::class, 'store'])
->name('bewerbung.store');
Route::get('bewerbungen', [BewerbungController::class, 'index'])->name('bewerbung.index');
Route::get('bewerbung/create', [BewerbungController::class, 'create'])->name('bewerbung.create');
Route::post('bewerbung', [BewerbungController::class, 'store'])->name('bewerbung.store');