with('tours',$tours); } public function index_bookings($tour_id) { $tour=Tour::find($tour_id); $bookings=array(); foreach($tour->getBookings($tour_id) as $booking) { array_push($bookings,$booking); } error_log("Tour:index_bookings, tour_id=".$tour->id); return view('tour.index_bookings')->with('tour',$tour)->with('bookings',$bookings); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ 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); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ 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'); } /** * Display the specified resource. * * @param \App\Tour $tour * @return \Illuminate\Http\Response */ public function show(Tour $tour) { return view('tour.show')->with('tour',$tour); } /** * Show the form for editing the specified resource. * * @param \App\Tour $tour * @return \Illuminate\Http\Response */ public function edit(Tour $tour) { error_log("Tour:edit"); return view('tour.edit')->with('tour',$tour); } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param \App\Tour $tour * @return \Illuminate\Http\Response */ public function update(Request $request, Tour $tour) { 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', 'bild'=>'mimes:jpg,jpeg,bmp,png,gif' ] ); if ($request->bild){ $bild = Image::make($request->bild); $breite = $bild->width(); $hoehe = $bild->height(); if ($breite>$hoehe) { Image::make($request->bild) ->widen(1200) ->save(public_path().'/img/tour/'.$tour->id.'_gross.jpg'); Image::make($request->bild) ->widen(64) ->save(public_path().'/img/tour/'.$tour->id.'.jpg'); }else { Image::make($request->bild) ->heighten(900) ->save(public_path().'/img/tour/'.$tour->id.'_gross.jpg'); Image::make($request->bild) ->widen(96) ->save(public_path().'/img/tour/'.$tour->id.'.jpg'); } } $tour->name=$request->input('name'); $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(); return redirect('/tour'); } /** * Remove the specified resource from storage. * * @param \App\Tour $tour * @return \Illuminate\Http\Response */ public function destroy(Tour $tour) { // } }