Skip to content

Commit

Permalink
Merge pull request #4360 from HDInnovations/Request-4353
Browse files Browse the repository at this point in the history
(Add) Display reports on torrent page
  • Loading branch information
HDVinnie authored Dec 2, 2024
2 parents 27a9dac + 72dd3c5 commit 8a5c9ae
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/TorrentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function show(Request $request, int|string $id): \Illuminate\Contracts\Vi
$user = $request->user();

$torrent = Torrent::withoutGlobalScope(ApprovedScope::class)
->with(['user', 'comments', 'category', 'type', 'resolution', 'subtitles', 'playlists'])
->with(['user', 'comments', 'category', 'type', 'resolution', 'subtitles', 'playlists', 'reports'])
->withCount([
'bookmarks',
'seeds' => fn ($query) => $query->where('active', '=', true)->where('visible', '=', true),
Expand Down
12 changes: 11 additions & 1 deletion app/Models/Torrent.php
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ public function bookmarks(): \Illuminate\Database\Eloquent\Relations\HasMany
}

/**
* Bookmarks.
* Resurrections.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany<Resurrection, $this>
*/
Expand All @@ -731,6 +731,16 @@ public function resurrections(): \Illuminate\Database\Eloquent\Relations\HasMany
return $this->hasMany(Resurrection::class);
}

/**
* Reports.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany<Report, $this>
*/
public function reports(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(Report::class);
}

/**
* Trump.
*
Expand Down
84 changes: 84 additions & 0 deletions resources/views/torrent/partials/reports.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<div class="panelV2" x-data="toggle">
<h2 class="panel__heading" style="cursor: pointer" x-on:click="toggle">
<i class="{{ config('other.font-awesome') }} fa-clipboard-list"></i>
Reports
<i
class="{{ config('other.font-awesome') }} fa-plus-circle fa-pull-right"
x-show="isToggledOff"
></i>
<i
class="{{ config('other.font-awesome') }} fa-minus-circle fa-pull-right"
x-show="isToggledOn"
x-cloak
></i>
</h2>
<div class="data-table-wrapper" x-show="isToggledOn" x-cloak>
<table class="data-table">
<thead>
<tr>
<th>{{ __('common.title') }}</th>
<th>Reported</th>
<th>
{{ __('common.reporter') }}
</th>
<th>
{{ __('common.created_at') }}
</th>
<th>
{{ __('common.staff') }}
</th>
<th>{{ __('forum.solved') }}</th>
</tr>
</thead>
<tbody>
@forelse ($torrent->reports as $report)
<tr>
<td>
<a href="{{ route('staff.reports.show', ['report' => $report]) }}">
{{ $report->title }}
</a>
</td>
<td>
<x-user_tag :anon="false" :user="$report->reported" />
</td>
<td>
<x-user_tag :anon="false" :user="$report->reporter" />
</td>
<td>
<time
datetime="{{ $report->created_at }}"
title="{{ $report->created_at }}"
>
{{ $report->created_at->toDayDateTimeString() }}
</time>
</td>
<td>
@if ($report->staff_id !== null)
<x-user_tag :anon="false" :user="$report->staff" />
@else
Unassigned
@endif
</td>
<td>
@if ($report->solved)
<i
class="{{ config('other.font-awesome') }} fa-check text-green"
></i>
{{ __('common.yes') }}
@else
<i
class="{{ config('other.font-awesome') }} fa-times text-red"
></i>
{{ __('common.no') }}
@endif
</td>
</tr>
@empty
<tr>
<td colspan="8">No reports</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
3 changes: 2 additions & 1 deletion resources/views/torrent/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@
@include('torrent.partials.tools')
@endif

{{-- Audits Block --}}
{{-- Audits, Reports, Downloads Block --}}
@if (auth()->user()->group->is_modo)
@include('torrent.partials.audits')
@include('torrent.partials.reports')
@include('torrent.partials.downloads')
@endif

Expand Down

0 comments on commit 8a5c9ae

Please sign in to comment.