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';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('bewerbungen', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('slug')->unique();
|
||||
$table->text('text')->nullable();
|
||||
$table->boolean('active')->default(false);
|
||||
$table->boolean('time')->default(false);
|
||||
$table->string('pdf_path')->nullable();
|
||||
$table->string('pic_path')->nullable();
|
||||
$table->string('bedingungen_path')->nullable();
|
||||
$table->timestamp('start_at')->nullable();
|
||||
$table->timestamp('end_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('bewerbungen');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('bands', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->string('phone')->nullable();
|
||||
$table->string('city')->nullable();
|
||||
$table->string('website')->nullable();
|
||||
$table->string('spotify')->nullable();
|
||||
$table->string('instagram')->nullable();
|
||||
$table->string('youtube')->nullable();
|
||||
$table->text('about')->nullable();
|
||||
$table->string('tech_rider_path')->nullable();
|
||||
$table->string('stage_plan_path')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('bands');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('band_applications', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('band_id')->constrained('bands')->cascadeOnDelete();
|
||||
$table->foreignId('bewerbung_id')->constrained('bewerbungen')->cascadeOnDelete();
|
||||
$table->string('status')->default('submitted');
|
||||
$table->text('message')->nullable();
|
||||
$table->string('demo_link')->nullable();
|
||||
$table->boolean('privacy_ok')->default(false);
|
||||
$table->timestamps();
|
||||
$table->unique(['band_id','bewerbung_id']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('band_applications');
|
||||
}
|
||||
};
|
||||
+3
-5
@@ -18,9 +18,7 @@ Route::get('/', function () {
|
||||
Route::get('info', function() {
|
||||
return view('info');
|
||||
});
|
||||
Route::get('bewerbung', function() {
|
||||
return view('bewerbung');
|
||||
});
|
||||
//Route::get('bewerbung', function() { return view('bewerbung');});
|
||||
Route::get('start', function() {
|
||||
return view('start');
|
||||
});
|
||||
@@ -33,5 +31,5 @@ Route::get('kontakt', function() {
|
||||
|
||||
|
||||
// Bewerbung CRUD
|
||||
Route::resource('bewerbungen', BewerbungController::class)
|
||||
->parameters(['bewerbungen' => 'bewerbung']); // ← erzwingt {bewerbung}
|
||||
//Route::resource('bewerbungen', BewerbungController::class)
|
||||
//->parameters(['bewerbungen' => 'bewerbung']); // ← erzwingt {bewerbung}
|
||||
Reference in new issue
Block a user