Showing image count per tour

This commit is contained in:
Torsten 2024-02-24 20:10:43 +01:00
parent 5c9f1229d4
commit 791623dc9d
2 changed files with 14 additions and 4 deletions

View file

@ -24,6 +24,9 @@
public function index()
{
error_log("Tour:index");
$tours = Tour::where('start', '>', Carbon::now())->orderBy('start')->get();
$participantCount = array();
foreach ($tours as $key => $tour) {
@ -37,16 +40,22 @@
public function index_old()
{
error_log("Tour:index_old");
Log::info("Tour:index_old");
$tours = Tour::where('start', '<', Carbon::now())->orderBy('start')->get();
$participantCount = array();
$imagecount_per_tour = 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);
$imagelist = Storage::disk('img_storage')->files("tour-$tour->id");
$len = sizeof($imagelist)/2;
$imagecount_per_tour[$tour->id]=$len;
Log::info("Tour $tour->id, ImageList size: $len");
}
return view('tour.index_old')->with('tours', $tours)->with('participantCount', $participantCount);
return view('tour.index_old')->with('tours', $tours)->with('participantCount', $participantCount)->with('imagecount_per_tour', $imagecount_per_tour);
}

View file

@ -16,9 +16,10 @@
<a href="/tour/{{$tour->id}}">
<li class="list-group-item d-flex justify-content-between align-items-center">
{{ $image_count = $imagecount_per_tour[$tour->id] }}
{{ $tour->start }} - {{ $tour->name }} [{{$participantCount[$tour->id]}}/{{$tour->max_participants}}]
<a href="/tour/gallery/{{$tour->id}}">(Galerie)</a>
<a href="/tour/gallery/{{$tour->id}}">( {{ $image_count }} Bilder)</a>
@if(App\Tour::has_participant($tour->id, Auth::user()->id)==true)
<i class="fas fa-biking"></i>
@endif