Tour-Überbuchung verhindern
This commit is contained in:
parent
134ac6478f
commit
4253194117
6 changed files with 621 additions and 560 deletions
|
|
@ -1,158 +1,159 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Tour;
|
||||
use App\Booking;
|
||||
use App\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\File;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Intervention\Image\Facades\Image;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Tour;
|
||||
use App\Booking;
|
||||
use App\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\File;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Intervention\Image\Facades\Image;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class TourController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
class TourController extends Controller
|
||||
{
|
||||
error_log("Tour:index");
|
||||
$tours=Tour::where('start','>',Carbon::now())->orderBy('start')->get();
|
||||
$participantCount=array();
|
||||
foreach($tours as $key => $tour) {
|
||||
$result = DB::select('select count(*) as cnt from bookings where tour_id=?', [$tour->id]);
|
||||
$participantCount[$tour->id] = $result[0]->cnt;
|
||||
$tours[$key]->start=Tour::toGermanDate($tour->start);
|
||||
$tours[$key]->deadline=Tour::toGermanDate($tour->deadline);
|
||||
}
|
||||
return view('tour.index')->with('tours',$tours)->with('participantCount',$participantCount);
|
||||
}
|
||||
|
||||
public function index_old()
|
||||
{
|
||||
error_log("Tour:index_old");
|
||||
$tours=Tour::where('start','<',Carbon::now())->orderBy('start')->get();
|
||||
$participantCount=array();
|
||||
foreach($tours as $key => $tour) {
|
||||
$result = DB::select('select count(*) as cnt from bookings where tour_id=?', [$tour->id]);
|
||||
$participantCount[$tour->id] = $result[0]->cnt;
|
||||
$tours[$key]->start=Tour::toGermanDate($tour->start);
|
||||
$tours[$key]->deadline=Tour::toGermanDate($tour->deadline);
|
||||
}
|
||||
return view('tour.index_old')->with('tours',$tours)->with('participantCount',$participantCount);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
/**
|
||||
* 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=Tour::toDBDate($request->input('start'));
|
||||
$tour->deadline=Tour::toDBDate($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)
|
||||
{
|
||||
$creator = User::find($tour->user_id);
|
||||
$bookings = Booking::where('tour_id',$tour->id)->get();
|
||||
$users = array();
|
||||
foreach($bookings as $booking) {
|
||||
$user=User::find($booking->user_id);
|
||||
array_push($users, $user);
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
error_log("Tour:index");
|
||||
$tours = Tour::where('start', '>', Carbon::now())->orderBy('start')->get();
|
||||
$participantCount = array();
|
||||
foreach ($tours as $key => $tour) {
|
||||
$result = DB::select('select count(*) as cnt from bookings where tour_id=?', [$tour->id]);
|
||||
$participantCount[$tour->id] = $result[0]->cnt;
|
||||
$tours[$key]->start = Tour::toGermanDate($tour->start);
|
||||
$tours[$key]->deadline = Tour::toGermanDate($tour->deadline);
|
||||
}
|
||||
return view('tour.index')->with('tours', $tours)->with('participantCount', $participantCount);
|
||||
}
|
||||
|
||||
// Vergangene Tour anzeigen
|
||||
if($tour->start < Carbon::now()) {
|
||||
public function index_old()
|
||||
{
|
||||
error_log("Tour:index_old");
|
||||
$tours = Tour::where('start', '<', Carbon::now())->orderBy('start')->get();
|
||||
$participantCount = array();
|
||||
foreach ($tours as $key => $tour) {
|
||||
$result = DB::select('select count(*) as cnt from bookings where tour_id=?', [$tour->id]);
|
||||
$participantCount[$tour->id] = $result[0]->cnt;
|
||||
$tours[$key]->start = Tour::toGermanDate($tour->start);
|
||||
$tours[$key]->deadline = Tour::toGermanDate($tour->deadline);
|
||||
}
|
||||
return view('tour.index_old')->with('tours', $tours)->with('participantCount', $participantCount);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
/**
|
||||
* 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 = Tour::toDBDate($request->input('start'));
|
||||
$tour->deadline = Tour::toDBDate($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)
|
||||
{
|
||||
$creator = User::find($tour->user_id);
|
||||
$bookings = Booking::where('tour_id', $tour->id)->get();
|
||||
$users = array();
|
||||
foreach ($bookings as $booking) {
|
||||
$user = User::find($booking->user_id);
|
||||
array_push($users, $user);
|
||||
}
|
||||
|
||||
// Vergangene Tour anzeigen
|
||||
if ($tour->start < Carbon::now()) {
|
||||
$tour->start = Tour::toGermanDate($tour->start);
|
||||
$tour->deadline = Tour::toGermanDate($tour->deadline);
|
||||
return view('tour.show_old')
|
||||
->with('tour', $tour)
|
||||
->with('users', $users)
|
||||
->with('creator', $creator);
|
||||
}
|
||||
|
||||
// Zukünftige Tour anzeigen
|
||||
$rooms = $this->fetch_rooms($tour->id);
|
||||
|
||||
$tour->start = Tour::toGermanDate($tour->start);
|
||||
$tour->deadline = Tour::toGermanDate($tour->deadline);
|
||||
return view('tour.show_old')
|
||||
return view('tour.show')
|
||||
->with('tour', $tour)
|
||||
->with('users', $users)
|
||||
->with('creator', $creator);
|
||||
->with('creator', $creator)
|
||||
->with('rooms', $rooms);
|
||||
}
|
||||
|
||||
// Zukünftige Tour anzeigen
|
||||
$rooms=$this->fetch_rooms($tour->id);
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Tour $tour
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
|
||||
$tour->start = Tour::toGermanDate($tour->start);
|
||||
$tour->deadline = Tour::toGermanDate($tour->deadline);
|
||||
return view('tour.show')
|
||||
->with('tour', $tour)
|
||||
->with('users', $users)
|
||||
->with('creator', $creator)
|
||||
->with('rooms', $rooms);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Tour $tour
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
|
||||
private function fetch_rooms($tour_id) {
|
||||
// - all existing rooms with booked users (if any)
|
||||
// - all users without room
|
||||
$sql="
|
||||
private function fetch_rooms($tour_id)
|
||||
{
|
||||
// - all existing rooms with booked users (if any)
|
||||
// - all users without room
|
||||
$sql = "
|
||||
SELECT
|
||||
qry.tour_id,
|
||||
qry.room_id,
|
||||
|
|
@ -176,7 +177,7 @@ class TourController extends Controller
|
|||
tour_rooms tr LEFT JOIN bookings as b
|
||||
ON b.tour_id = tr.tour_id AND b.room_id = tr.id
|
||||
WHERE
|
||||
tr.tour_id= ".$tour_id."
|
||||
tr.tour_id= " . $tour_id . "
|
||||
|
||||
) qry
|
||||
LEFT JOIN users as u
|
||||
|
|
@ -201,7 +202,7 @@ class TourController extends Controller
|
|||
LEFT JOIN tour_rooms as tr
|
||||
ON b.room_id = tr.id
|
||||
WHERE
|
||||
b.tour_id= ".$tour_id."
|
||||
b.tour_id= " . $tour_id . "
|
||||
AND
|
||||
b.user_id = u.id
|
||||
AND
|
||||
|
|
@ -210,163 +211,174 @@ class TourController extends Controller
|
|||
;
|
||||
";
|
||||
|
||||
$rooms=DB::select($sql);
|
||||
$rooms = DB::select($sql);
|
||||
|
||||
Log::info("TourController.fetch_rooms, returning rooms result:");
|
||||
Log::info($rooms);
|
||||
//Log::info("TourController.fetch_rooms, returning rooms result:");
|
||||
//Log::info($rooms);
|
||||
|
||||
return($rooms);
|
||||
}
|
||||
|
||||
public function edit(Tour $tour)
|
||||
{
|
||||
if (Auth::user()->role != 'ADMIN') {return redirect('/tour');}
|
||||
error_log("Tour:edit");
|
||||
if ($tour->start<Carbon::now()) {
|
||||
return view('tour.edit_old')->with('tour', $tour);
|
||||
return ($rooms);
|
||||
}
|
||||
|
||||
$tour->start = Tour::toGermanDate($tour->start);
|
||||
$tour->deadline = Tour::toGermanDate($tour->deadline);
|
||||
|
||||
$rooms = $this->fetch_rooms($tour->id);
|
||||
|
||||
|
||||
|
||||
return view('tour.edit')
|
||||
->with('tour', $tour)
|
||||
->with('rooms', $rooms);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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',
|
||||
'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');
|
||||
public function edit(Tour $tour)
|
||||
{
|
||||
if (Auth::user()->role != 'ADMIN') {
|
||||
return redirect('/tour');
|
||||
}
|
||||
error_log("Tour:edit");
|
||||
if ($tour->start < Carbon::now()) {
|
||||
return view('tour.edit_old')->with('tour', $tour);
|
||||
}
|
||||
|
||||
$tour->start = Tour::toGermanDate($tour->start);
|
||||
$tour->deadline = Tour::toGermanDate($tour->deadline);
|
||||
|
||||
$rooms = $this->fetch_rooms($tour->id);
|
||||
|
||||
|
||||
return view('tour.edit')
|
||||
->with('tour', $tour)
|
||||
->with('rooms', $rooms);
|
||||
}
|
||||
|
||||
$tour->name=$request->input('name');
|
||||
if ($request->beschreibung) $tour->beschreibung=$request->input('beschreibung');
|
||||
if ($request->start) $tour->start=Tour::toDBDate($request->input('start'));
|
||||
if ($request->deadline) $tour->deadline=Tour::toDBDate($request->input('deadline'));
|
||||
if ($request->max_participants) $tour->max_participants=$request->input('max_participants');
|
||||
$tour->is_cancelled= ($request->has('is_cancelled'));
|
||||
if ($request->bericht) $tour->bericht=$request->bericht;
|
||||
$tour->save();
|
||||
/**
|
||||
* 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',
|
||||
'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');
|
||||
if ($request->beschreibung) $tour->beschreibung = $request->input('beschreibung');
|
||||
if ($request->start) $tour->start = Tour::toDBDate($request->input('start'));
|
||||
if ($request->deadline) $tour->deadline = Tour::toDBDate($request->input('deadline'));
|
||||
if ($request->max_participants) $tour->max_participants = $request->input('max_participants');
|
||||
$tour->is_cancelled = ($request->has('is_cancelled'));
|
||||
if ($request->bericht) $tour->bericht = $request->bericht;
|
||||
$tour->save();
|
||||
|
||||
|
||||
error_log("Is cancelled:". $tour->is_cancelled);
|
||||
error_log("Is cancelled:" . $tour->is_cancelled);
|
||||
|
||||
return redirect('/tour');
|
||||
return redirect('/tour');
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
public function create_room($tour_id, $capacity) {
|
||||
DB::delete("INSERT INTO booking_rooms")
|
||||
}
|
||||
*/
|
||||
|
||||
public function upload_gallery(Request $request, Tour $tour){
|
||||
dd($request);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Tour $tour
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Tour $tour)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function join_room($tour_id,$room_id) {
|
||||
Log::info("TourController::join_room");
|
||||
$user_id = Auth::user()->id;
|
||||
Tour::join_room($tour_id,$user_id, $room_id);
|
||||
return redirect('/tour/'.$tour_id);
|
||||
}
|
||||
public function join_room4user($tour_id,$room_id,$user_id) {
|
||||
Log::info("TourController::join_room");
|
||||
Tour::join_room($tour_id,$user_id, $room_id);
|
||||
|
||||
$tour = Tour::find($tour_id);
|
||||
$tour->start = Tour::toGermanDate($tour->start);
|
||||
$tour->deadline = Tour::toGermanDate($tour->deadline);
|
||||
|
||||
$rooms = $this->fetch_rooms($tour->id);
|
||||
|
||||
return view('tour.edit')
|
||||
->with('tour', $tour)
|
||||
->with('rooms', $rooms);
|
||||
|
||||
return redirect('/tour/'.$tour_id);
|
||||
}
|
||||
public function cancelBooking($tour_id) {
|
||||
$user=Auth::user();
|
||||
Booking::where('tour_id', $tour_id)->where('user_id', $user->id)->delete();
|
||||
return redirect('/tour');
|
||||
}
|
||||
|
||||
public function cancelBookingAdmin($tour_id, $user_id) {
|
||||
$user=Auth::user();
|
||||
if (Auth::user()->role == "ADMIN") {
|
||||
Booking::where('tour_id', $tour_id)->where('user_id', $user_id)->delete();
|
||||
}
|
||||
return redirect('/tour/'.$tour_id);
|
||||
}
|
||||
|
||||
public function create_room($tour_id,$capacity) {
|
||||
Log::info("create_room Controller started");
|
||||
$user=Auth::user();
|
||||
Tour::create_room($tour_id,$capacity);
|
||||
return redirect('tour/'.$tour_id.'/edit');
|
||||
}
|
||||
public function delete_room($tour_id,$room_id) {
|
||||
Log::info("create_room Controller started");
|
||||
$user=Auth::user();
|
||||
/*
|
||||
public function create_room($tour_id, $capacity) {
|
||||
DB::delete("INSERT INTO booking_rooms")
|
||||
}
|
||||
*/
|
||||
|
||||
DB::update("UPDATE bookings SET room_id=0 WHERE room_id=".$room_id);
|
||||
DB::delete("DELETE FROM tour_rooms WHERE tour_id = ? AND id = ?",[$tour_id, $room_id]);
|
||||
return redirect('tour/'.$tour_id.'/edit');
|
||||
public function upload_gallery(Request $request, Tour $tour)
|
||||
{
|
||||
dd($request);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Tour $tour
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Tour $tour)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function join_room($tour_id, $room_id)
|
||||
{
|
||||
Log::info("TourController::join_room");
|
||||
$user_id = Auth::user()->id;
|
||||
Tour::join_room($tour_id, $user_id, $room_id);
|
||||
return redirect('/tour/' . $tour_id);
|
||||
}
|
||||
|
||||
public function join_room4user($tour_id, $room_id, $user_id)
|
||||
{
|
||||
Log::info("TourController::join_room");
|
||||
Tour::join_room($tour_id, $user_id, $room_id);
|
||||
|
||||
$tour = Tour::find($tour_id);
|
||||
$tour->start = Tour::toGermanDate($tour->start);
|
||||
$tour->deadline = Tour::toGermanDate($tour->deadline);
|
||||
|
||||
$rooms = $this->fetch_rooms($tour->id);
|
||||
|
||||
return view('tour.edit')
|
||||
->with('tour', $tour)
|
||||
->with('rooms', $rooms);
|
||||
|
||||
return redirect('/tour/' . $tour_id);
|
||||
}
|
||||
|
||||
public function cancelBooking($tour_id)
|
||||
{
|
||||
$user = Auth::user();
|
||||
Booking::where('tour_id', $tour_id)->where('user_id', $user->id)->delete();
|
||||
return redirect('/tour');
|
||||
}
|
||||
|
||||
public function cancelBookingAdmin($tour_id, $user_id)
|
||||
{
|
||||
$user = Auth::user();
|
||||
if (Auth::user()->role == "ADMIN") {
|
||||
Booking::where('tour_id', $tour_id)->where('user_id', $user_id)->delete();
|
||||
}
|
||||
return redirect('/tour/' . $tour_id);
|
||||
}
|
||||
|
||||
public function create_room($tour_id, $capacity)
|
||||
{
|
||||
Log::info("create_room Controller started");
|
||||
$user = Auth::user();
|
||||
Tour::create_room($tour_id, $capacity);
|
||||
return redirect('tour/' . $tour_id . '/edit');
|
||||
}
|
||||
|
||||
public function delete_room($tour_id, $room_id)
|
||||
{
|
||||
Log::info("create_room Controller started");
|
||||
$user = Auth::user();
|
||||
|
||||
DB::update("UPDATE bookings SET room_id=0 WHERE room_id=" . $room_id);
|
||||
DB::delete("DELETE FROM tour_rooms WHERE tour_id = ? AND id = ?", [$tour_id, $room_id]);
|
||||
return redirect('tour/' . $tour_id . '/edit');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue