Route downloads through controller; file IDs as hash to prevent guessing; download count; download list on airport page

This commit is contained in:
Nabeel Shahzad
2018-04-02 12:55:37 -05:00
parent 3ddee56359
commit 9e1e0142e9
8 changed files with 131 additions and 11 deletions

View File

@@ -16,7 +16,8 @@ Pass in:
<thead>
<tr>
<td>Name</td>
<td>Current File</td>
<td>Direct Link</td>
<td>Downloads</td>
<td class="text-right"></td>
</tr>
</thead>
@@ -26,6 +27,7 @@ Pass in:
<tr>
<td>{{ $file->name }}</td>
<td><a href="{{ $file->url }}" target="_blank">Link to file</a></td>
<td>{{$file->download_count}}</td>
<td class="text-right">
{{ Form::open(['route' => ['admin.files.delete', $file->id], 'method' => 'delete']) }}
{{ Form::hidden('id', $file->id) }}

View File

@@ -2,17 +2,19 @@
@section('title', $airport->full_name)
@section('content')
<div class="row">
<div class="row" style="margin-bottom: 30px;">
<div class="col-12">
<h2 class="description">{{ $airport->full_name }}</h2>
</div>
<div class="col-5">
{{-- Show the weather widget in one column --}}
<div class="col-5">
{{ Widget::checkWx([
'icao' => $airport->icao,
]) }}
</div>
{{-- Show the airspace map in the other column --}}
<div class="col-7">
{{ Widget::airspaceMap([
'width' => '100%',
@@ -22,21 +24,47 @@
]) }}
</div>
</div>
<div class="row" style="height: 30px;">
<div class="row" style="margin-bottom: 30px;">
{{-- There are files uploaded and a user is logged in--}}
@if($airport->files && Auth::check())
<div class="col-12">
<h3 class="description">Downloads</h3>
<ul class="list-group">
@foreach($airport->files as $file)
<li class="list-group-item">
<a href="{{route('frontend.files.show', [$file->id])}}" target="_blank">
{{ $file->name }}
</a>
{{-- only show description is one is provided --}}
@if($file->description)
- {{$file->description}}
@endif
<span style="margin-left: 20px">{{$file->download_count}} downloads</span>
</li>
@endforeach
</ul>
</div>
@endif
</div>
<div class="row">
<div class="col-md-12">
<h3 class="description">Inbound Flights</h3>
@if(!$inbound_flights)
<div class="mini-splash">
<div class="jumbotron text-center">
no flights found
</div>
@else
@each('airports.table', $inbound_flights, 'flight')
@endif
<h3 class="description">Outbound Flights</h3>
@each('airports.table', $outbound_flights, 'flight')
@if(!$outbound_flights)
<div class="jumbotron text-center">
no flights found
</div>
@else
@each('airports.table', $outbound_flights, 'flight')
@endif
</div>
</div>
@endsection