diff --git a/motorradig/app/Http/Controllers/TourController.php b/motorradig/app/Http/Controllers/TourController.php index 20c3c0b..dd18bef 100644 --- a/motorradig/app/Http/Controllers/TourController.php +++ b/motorradig/app/Http/Controllers/TourController.php @@ -7,7 +7,7 @@ use Illuminate\Http\Request; use Illuminate\Http\File; use Illuminate\Support\Facades\Storage; use Intervention\Image\Facades\Image; - +use Illuminate\Support\Facades\Auth; class TourController extends Controller { @@ -18,6 +18,7 @@ class TourController extends Controller */ public function index() { + error_log("Tour:index"); $tours=Tour::all(); return view('tour.index')->with('tours',$tours); } @@ -29,7 +30,12 @@ class TourController extends Controller */ public function create() { - // + error_log("Tour:create"); + $tour = new Tour; + $tour->name="neue Tour"; + $tour->beschreibung="Tour Beschreibung"; + $tour->user_id=Auth::user()->id; + return view('tour.create')->with('tour',$tour); } /** @@ -40,7 +46,32 @@ class TourController extends Controller */ public function store(Request $request) { - // + error_log("Tour:store"); + + $request->validate( + [ + 'name'=>'required|min:3', + 'beschreibung'=>'required', + 'start'=>'required', + 'deadline'=>'required', + 'user_id'=>'required', + 'bild'=>'mimes:jpg,jpeg,bmp,png,gif' + ] + ); + + $tour=new Tour; + $tour->name=$request->input('name'); + $tour->user_id=$request->input('user_id'); + $tour->beschreibung=$request->input('beschreibung'); + $tour->start=$request->input('start'); + $tour->deadline=$request->input('deadline'); + $tour->max_participants=$request->input('max_participants'); + $tour->is_cancelled=$request->input('is_cancelled',false); + $tour->save(); + + error_log("Stored deadline:".$tour->deadline); + + return redirect('/tour'); } /** @@ -62,7 +93,8 @@ class TourController extends Controller */ public function edit(Tour $tour) { - // + error_log("Tour:edit"); + return view('tour.edit')->with('tour',$tour); } /** @@ -74,10 +106,12 @@ class TourController extends Controller */ public function update(Request $request, Tour $tour) { - $tour=Tour::find($request->input('id')); + error_log("Tour:update"); + $tour=Tour::find($request->input('tour_id')); $request->validate( [ + 'tour_id' => 'required', 'name'=>'required|min:3', 'beschreibung'=>'required', 'user_id'=>'required', @@ -108,12 +142,14 @@ class TourController extends Controller $tour->name=$request->input('name'); $tour->beschreibung=$request->input('beschreibung'); - $tour->is_cancelled=$request->input('is_cancelled'); $tour->start=$request->input('start'); $tour->deadline=$request->input('deadline'); + $tour->max_participants=$request->input('max_participants'); + $tour->is_cancelled=$request->input('is_cancelled',false); + $tour->save(); - return redirect('/member/'); + return redirect('/tour'); } @@ -128,5 +164,4 @@ class TourController extends Controller // } - } diff --git a/motorradig/app/Tour.php b/motorradig/app/Tour.php index 331bae3..794b9e1 100644 --- a/motorradig/app/Tour.php +++ b/motorradig/app/Tour.php @@ -6,5 +6,7 @@ use Illuminate\Database\Eloquent\Model; class Tour extends Model { - // + protected $fillable = [ + 'id', 'name', 'beschreibung','user_id','start','deadline' + ]; } diff --git a/motorradig/database/migrations/2020_09_30_082629_create_tours_table.php b/motorradig/database/migrations/2020_09_30_082629_create_tours_table.php index 43b1d6a..ad9f84d 100644 --- a/motorradig/database/migrations/2020_09_30_082629_create_tours_table.php +++ b/motorradig/database/migrations/2020_09_30_082629_create_tours_table.php @@ -18,10 +18,10 @@ class CreateToursTable extends Migration $table->string('name'); $table->text('beschreibung'); $table->string('user_id'); - $table->integer('max_participants'); + $table->integer('max_participants')->default(5); $table->date('start')->nullable(); $table->date('deadline')->nullable(); - $table->boolean('is_cancelled'); + $table->boolean('is_cancelled')->default(false); $table->timestamps(); }); } diff --git a/motorradig/public/img/placeholder/tour128x100.jpg b/motorradig/public/img/placeholder/tour128x100.jpg new file mode 100644 index 0000000..b59e1cd Binary files /dev/null and b/motorradig/public/img/placeholder/tour128x100.jpg differ diff --git a/motorradig/resources/views/tour/create.blade.php b/motorradig/resources/views/tour/create.blade.php new file mode 100644 index 0000000..f034fcc --- /dev/null +++ b/motorradig/resources/views/tour/create.blade.php @@ -0,0 +1,80 @@ +@extends('layouts.app') + +@section('content') +
-
- @else
-
- @endif
+
+
+
+ @else
+
+ @endif