Public Access
zwischencommit
This commit is contained in:
1 parent
bdb62a6ce2
commit
ed07d3ef70
8 files changed
+263
-5
No files matched your search
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Band;
|
||||
use App\Models\Bewerbung;
|
||||
use App\Models\BandApplication;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class BandApplicationController extends Controller
|
||||
{
|
||||
/**
|
||||
* Speichert eine Bewerbung (Band-Stammdaten + Bewerbung zur Runde).
|
||||
* Route: POST /bewerbung/{bewerbung:slug}/apply (name: band.apply)
|
||||
*/
|
||||
public function store(Request $request, Bewerbung $bewerbung)
|
||||
{
|
||||
// Validierung
|
||||
$data = $request->validate([
|
||||
// Band-Stammdaten
|
||||
'band.name' => ['required','string','max:255'],
|
||||
'band.email' => ['required','email','max:255'],
|
||||
'band.phone' => ['nullable','string','max:100'],
|
||||
'band.city' => ['nullable','string','max:255'],
|
||||
'band.website' => ['nullable','url','max:255'],
|
||||
'band.spotify' => ['nullable','url','max:255'],
|
||||
'band.instagram' => ['nullable','url','max:255'],
|
||||
'band.youtube' => ['nullable','url','max:255'],
|
||||
'band.about' => ['nullable','string','max:5000'],
|
||||
|
||||
// Dateien optional
|
||||
'band.tech_rider' => ['nullable','file','mimes:pdf','max:8192'],
|
||||
'band.stage_plan' => ['nullable','file','mimes:pdf','max:8192'],
|
||||
|
||||
// Bewerbung
|
||||
'message' => ['nullable','string','max:5000'],
|
||||
'demo_link' => ['nullable','url','max:255'],
|
||||
'privacy_ok' => ['accepted'], // muss angehakt sein
|
||||
]);
|
||||
|
||||
$application = DB::transaction(function() use ($data, $request, $bewerbung) {
|
||||
|
||||
// 1) Band per E-Mail finden/neu anlegen
|
||||
$band = Band::firstOrNew(['email' => $data['band']['email']]);
|
||||
$band->fill([
|
||||
'name' => $data['band']['name'],
|
||||
'phone' => $data['band']['phone'] ?? null,
|
||||
'city' => $data['band']['city'] ?? null,
|
||||
'website' => $data['band']['website'] ?? null,
|
||||
'spotify' => $data['band']['spotify'] ?? null,
|
||||
'instagram' => $data['band']['instagram'] ?? null,
|
||||
'youtube' => $data['band']['youtube'] ?? null,
|
||||
'about' => $data['band']['about'] ?? null,
|
||||
]);
|
||||
|
||||
if ($request->hasFile('band.tech_rider')) {
|
||||
$band->tech_rider_path = $request->file('band.tech_rider')->store('bands/tech', 'public');
|
||||
}
|
||||
if ($request->hasFile('band.stage_plan')) {
|
||||
$band->stage_plan_path = $request->file('band.stage_plan')->store('bands/stage', 'public');
|
||||
}
|
||||
$band->save();
|
||||
|
||||
// 2) Bewerbungs-Duplikate verhindern
|
||||
$existing = BandApplication::where('band_id', $band->id)
|
||||
->where('bewerbung_id', $bewerbung->id)
|
||||
->first();
|
||||
|
||||
if ($existing) {
|
||||
// Optional: Nachricht/Demolink aktualisieren
|
||||
$existing->update([
|
||||
'message' => $data['message'] ?? $existing->message,
|
||||
'demo_link' => $data['demo_link'] ?? $existing->demo_link,
|
||||
]);
|
||||
return $existing;
|
||||
}
|
||||
|
||||
// 3) Bewerbung anlegen
|
||||
return BandApplication::create([
|
||||
'band_id' => $band->id,
|
||||
'bewerbung_id' => $bewerbung->id,
|
||||
'status' => 'submitted',
|
||||
'message' => $data['message'] ?? null,
|
||||
'demo_link' => $data['demo_link'] ?? null,
|
||||
'privacy_ok' => true,
|
||||
]);
|
||||
});
|
||||
|
||||
return redirect()
|
||||
->route('bewerbung.show', $bewerbung) // oder ['bewerbung' => $bewerbung->slug]
|
||||
->with('success', 'Danke! Eure Bewerbung ist eingegangen.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Band extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'phone',
|
||||
'city',
|
||||
'website',
|
||||
'spotify',
|
||||
'instagram',
|
||||
'youtube',
|
||||
'about',
|
||||
'tech_rider_path',
|
||||
'stage_plan_path',
|
||||
];
|
||||
|
||||
public function applications()
|
||||
{
|
||||
return $this->hasMany(BandApplication::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class BandApplication extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'band_id',
|
||||
'bewerbung_id',
|
||||
'status', // submitted, in_review, accepted, rejected
|
||||
'message',
|
||||
'demo_link',
|
||||
'privacy_ok',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'privacy_ok' => 'boolean',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function band()
|
||||
{
|
||||
return $this->belongsTo(Band::class);
|
||||
}
|
||||
|
||||
public function bewerbung()
|
||||
{
|
||||
return $this->belongsTo(Bewerbung::class);
|
||||
}
|
||||
}
|
||||
@@ -28,4 +28,15 @@ class Bewerbung extends Model
|
||||
'start_at' => 'datetime',
|
||||
'end_at' => 'datetime',
|
||||
];
|
||||
// app/Models/Bewerbung.php
|
||||
public function applications()
|
||||
{
|
||||
return $this->hasMany(\App\Models\BandApplication::class, 'bewerbung_id');
|
||||
}
|
||||
|
||||
public function getRouteKeyName()
|
||||
{
|
||||
return 'slug';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user