added Orte-Table
This commit is contained in:
parent
8b98db74a2
commit
8cfa2762db
@ -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
app/Ort.php
Normal file
10
app/Ort.php
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
46
database/migrations/2017_07_08_100720_AddOrtTable.php
Normal file
46
database/migrations/2017_07_08_100720_AddOrtTable.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddOrtTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('orte', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
|
||||
$table->string('name',50);
|
||||
});
|
||||
|
||||
Schema::table('veranstaltungen', function (Blueprint $table) {
|
||||
|
||||
$table->integer('ort_id')->unsigned()->nullable();
|
||||
$table->foreign('ort_id')->references('id')->on('orte');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
|
||||
|
||||
Schema::table('veranstaltungen', function (Blueprint $table) {
|
||||
|
||||
$table->dropColumn('ort_id');
|
||||
});
|
||||
|
||||
Schema::dropIfExists('orte');
|
||||
}
|
||||
}
|
||||
@ -14,5 +14,7 @@ class DatabaseSeeder extends Seeder
|
||||
// $this->call(UsersTableSeeder::class);
|
||||
$this->call('ArbeitsplatzSeeder');
|
||||
$this->command->info('Arbeitsplatz-table seeded!');
|
||||
$this->call('OrteSeeder');
|
||||
$this->command->info("Orte-table seeded!");
|
||||
}
|
||||
}
|
||||
|
||||
22
database/seeds/OrteSeeder.php
Normal file
22
database/seeds/OrteSeeder.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Ort;
|
||||
|
||||
class OrteSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
Ort::firstOrCreate(['name' => 'großes Haus']);
|
||||
Ort::firstOrCreate(['name' => 'Studiobühne']);
|
||||
Ort::firstOrCreate(['name' => 'Theatrium']);
|
||||
Ort::firstOrCreate(['name' => 'Foyer']);
|
||||
Ort::firstOrCreate(['name' => 'Domstufen']);
|
||||
Ort::firstOrCreate(['name' => 'siehe Hinweise']);
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
3559
public/js/app.js
3559
public/js/app.js
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user