View alter Touren, TourSeeder mit alter Tour, Verlinkung

This commit is contained in:
TorstenS 2020-10-13 10:20:48 +02:00
parent 79b3720e8f
commit e6f3767e33
8 changed files with 238 additions and 10 deletions

View file

@ -5,6 +5,7 @@ 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\Storage;
@ -22,7 +23,7 @@ class TourController extends Controller
public function index()
{
error_log("Tour:index");
$tours=Tour::all();
$tours=Tour::where('start','>',Carbon::now())->get();
$participantCount=array();
foreach($tours as $tour) {
$result = DB::select('select count(*) as cnt from bookings where tour_id=?', [$tour->id]);
@ -31,6 +32,19 @@ class TourController extends Controller
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())->get();
$participantCount=array();
foreach($tours as $tour) {
$result = DB::select('select count(*) as cnt from bookings where tour_id=?', [$tour->id]);
$participantCount[$tour->id] = $result[0]->cnt;
}
return view('tour.index_old')->with('tours',$tours)->with('participantCount',$participantCount);
}
/*
@ -206,4 +220,5 @@ class TourController extends Controller
return redirect('/tour/'.$tour_id);
}
}