added Orte-Table
This commit is contained in:
+4
-1
@@ -7,7 +7,10 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class Eintragung extends Model
|
||||
{
|
||||
protected $table = "eintragungen";
|
||||
protected $dates = ['kann_ab', 'kann_bis'];
|
||||
protected $dates = ['kann_ab', 'kann_bis', 'created_at', 'updated_at'];
|
||||
protected $casts = [
|
||||
'nicht_unbedingt' => 'boolean',
|
||||
];
|
||||
|
||||
public function veranstaltung(){
|
||||
return $this->belongsTo('App\Veranstaltung');
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Veranstaltung;
|
||||
use App\Eintragung;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
@@ -66,8 +67,9 @@ class VeranstaltungController extends Controller
|
||||
*/
|
||||
public function show(Veranstaltung $veranstaltung)
|
||||
{
|
||||
|
||||
if ($veranstaltung->has('eintragungen')) {
|
||||
$veranstaltung->eintragungen;
|
||||
$veranstaltung = $veranstaltung->with('eintragungen.user')->find($veranstaltung->id);
|
||||
}
|
||||
return view('veranstaltung.show', $veranstaltung);
|
||||
}
|
||||
@@ -124,6 +126,12 @@ class VeranstaltungController extends Controller
|
||||
|
||||
public function enter(Request $request, Veranstaltung $veranstaltung)
|
||||
{
|
||||
|
||||
$eintragung = new Eintragung();
|
||||
$eintragung->veranstaltung()->associate($veranstaltung);
|
||||
$eintragung->user()->associate(\Auth::user());
|
||||
if($eintragung->save()){
|
||||
return redirect()->route('veranstaltung.index');
|
||||
}
|
||||
return response()->json($eintragung);
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Ort extends Model
|
||||
{
|
||||
protected $table = "orte";
|
||||
}
|
||||
@@ -10,7 +10,7 @@ class Veranstaltung extends Model
|
||||
|
||||
protected $fillable = ['name','beginn','ende','geaste','hinweise'];
|
||||
|
||||
protected $dates = ['beginn', 'ende'];
|
||||
protected $dates = ['beginn', 'ende', 'created_at', 'updated_at'];
|
||||
|
||||
public function eintragungen(){
|
||||
return $this->hasMany('App\Eintragung');
|
||||
@@ -19,4 +19,10 @@ class Veranstaltung extends Model
|
||||
public function einteilungen(){
|
||||
return $this->hasMany('App\Einteilung');
|
||||
}
|
||||
|
||||
public function getIstEingetragenAttribute(){
|
||||
$amI = $this->eintragungen->count('user_id', "=", \Auth::id());
|
||||
|
||||
return $amI > 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user