Skip to content

Commit

Permalink
✨ add page for information about trips
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKrisKrisu committed Dec 29, 2024
1 parent 35f94b6 commit c99e1f9
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 2 deletions.
8 changes: 8 additions & 0 deletions app/Http/Controllers/FrontendTransportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
use App\DataProviders\Hafas;
use App\Exceptions\HafasException;
use App\Http\Controllers\TransportController as TransportBackend;
use App\Models\Trip;
use Illuminate\Http\JsonResponse;
use Illuminate\View\View;

/**
* @deprecated Content will be moved to the backend/frontend/API packages soon, please don't add new functions here!
Expand All @@ -22,4 +24,10 @@ public function TrainAutocomplete(string $station): JsonResponse {
abort(503, $e->getMessage());
}
}

public function getTrip(int $tripId): View {
return view('trip-info', [
'trip' => Trip::findOrFail($tripId)
]);
}
}
11 changes: 10 additions & 1 deletion lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -819,5 +819,14 @@
"welcome.stats.million": "Millionen",
"welcome.stats.distance": "kilometer gereist",
"welcome.stats.registered": "Registrierte user",
"welcome.stats.duration": "Jahre Reisezeit"
"welcome.stats.duration": "Jahre Reisezeit",
"trip-info.title": ":linename am :date",
"trip-info.stopovers": "Zwischenhalte",
"trip-info.stopover": "Zwischenhalt",
"trip-info.departure": "Abfahrt",
"trip-info.arrival": "Ankunft",
"trip-info.in-this-connection": "In dieser Verbindung",
"trip-info.user": "User",
"trip-info.origin": "Abfahrtsort",
"trip-info.destination": "Zielort"
}
11 changes: 10 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -819,5 +819,14 @@
"welcome.stats.million": "Million",
"welcome.stats.distance": "kilometers travelled",
"welcome.stats.registered": "users registered",
"welcome.stats.duration": "years travel time"
"welcome.stats.duration": "years travel time",
"trip-info.title": ":linename at :date",
"trip-info.stopovers": "Stopovers",
"trip-info.stopover": "Stopover",
"trip-info.departure": "Departure",
"trip-info.arrival": "Arrival",
"trip-info.in-this-connection": "In this connection",
"trip-info.user": "User",
"trip-info.origin": "Origin",
"trip-info.destination": "Destination"
}
75 changes: 75 additions & 0 deletions resources/views/trip-info.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
@extends('layouts.app')

@section('title', __('trip-info.title', ['linename' => $trip->linename, 'date' => $trip->departure->format('d.m.Y')]))

@section('content')
<div class="container">
<div class="row">
<div class="col-12">
<h1>{{__('trip-info.title', ['linename' => $trip->linename, 'date' => $trip->departure->format('d.m.Y')])}}</h1>

<div class="alert alert-info">
Diese Seite gehört zu den experimentellen Features von Träwelling.
Daher sieht sie auch nicht schön aus, zeigt nur generische Infos und ist nirgends verlinkt.
Du kannst sie gerne verbessern und einen PullRequest schicken.
</div>
</div>

<div class="col-md-7">
<h2>{{__('trip-info.stopovers')}}</h2>

<table class="table table-striped table-bordered">
<thead>
<tr>
<th>{{__('trip-info.stopover')}}</th>
<th>{{__('trip-info.arrival')}}</th>
<th>{{__('trip-info.departure')}}</th>
</tr>
</thead>
<tbody>
@foreach($trip->stopovers as $stopover)
<tr>
<td>{{$stopover->station->name}}</td>
<td>{{$stopover->arrival->format('H:i')}}</td>
<td>{{$stopover->departure->format('H:i')}}</td>
</tr>
@endforeach
</tbody>
</table>
</div>

<div class="col-md-5">
<h2>{{__('trip-info.in-this-connection')}}</h2>
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>{{__('trip-info.user')}}</th>
<th>{{__('trip-info.origin')}}</th>
<th>{{__('trip-info.destination')}}</th>
</tr>
</thead>
<tbody>
@foreach($trip->checkins as $checkin)
@can('view', $checkin->status)
<tr>
<td>
<a href="{{route('profile', ['username' => $checkin->user->username])}}">
<img
src="{{\App\Http\Controllers\Backend\User\ProfilePictureController::getUrl($checkin->user)}}"
alt="{{$checkin->user->name}}" style="max-height: 1em;"
class="avatar">
{{$checkin->user->name}}
</a>
</td>
<td>{{$checkin->originStopover->station->name}}</td>
<td>{{$checkin->destinationStopover->station->name}}</td>
</tr>
@endcan
@endforeach
</tbody>
</table>
</div>
</div>
</div>

@endsection
3 changes: 3 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@
->whereNumber('id')
->name('status');

Route::get('/trip/{id}', [FrontendTransportController::class, 'getTrip'])
->whereNumber('id');

/**
* These routes can be used by logged in users although they have not signed the privacy policy yet.
*/
Expand Down

0 comments on commit c99e1f9

Please sign in to comment.