add: user following page

This commit is contained in:
Roardom
2023-06-17 08:38:35 +00:00
parent a4b34f4798
commit ccb81092da
5 changed files with 115 additions and 0 deletions
@@ -0,0 +1,33 @@
<?php
/**
* NOTICE OF LICENSE.
*
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D Community Edition
*
* @author Roardom <roardom@protonmail.com>
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
*/
namespace App\Http\Controllers\User;
use App\Http\Controllers\Controller;
use App\Models\User;
class FollowingController extends Controller
{
/**
* User Followers.
*/
public function index(User $user): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
{
$followings = $user->following()->orderByPivot('created_at', 'desc')->paginate(25);
return view('user.following.index', [
'followings' => $followings,
'user' => $user,
]);
}
}
+1
View File
@@ -110,6 +110,7 @@ return [
'follower-help' => 'Control the sharing of specific follower related information with groups that are allowed to access to your profile.
These settings are overridden if you do not allow any groups to access your followers or if you <strong>Go Private</strong>',
'followers' => 'Followers',
'following' => 'Following',
'following-notification' => 'Followed User Notification Settings',
'following-notification-upload' => 'Receive a notification when a followed user uploads a torrent',
'following-notification-help' => 'Control which notifications are sent concerning followed user site actions.
@@ -260,6 +260,16 @@
</a>
</li>
@endif
@if (auth()->user()->group->is_modo || auth()->id() === $user->id)
<li class="{{ Route::is('users.following.index') ? 'nav-tab--active' : 'nav-tavV2' }}">
<a
class="{{ Route::is('users.following.index') ? 'nav-tab--active__link' : 'nav-tab__link' }}"
href="{{ route('users.following.index', ['user' => $user]) }}"
>
{{ __('user.following') }}
</a>
</li>
@endif
</ul>
</li>
@endif
@@ -0,0 +1,66 @@
@extends('layout.default')
@section('title')
<title>{{ $user->username }} {{ __('user.following') }} - {{ config('other.title') }}</title>
@endsection
@section('breadcrumbs')
<li class="breadcrumbV2">
<a href="{{ route('users.show', ['username' => $user->username]) }}" class="breadcrumb__link">
{{ $user->username }}
</a>
</li>
<li class="breadcrumb--active">
{{ __('user.following') }}
</li>
@endsection
@section('nav-tabs')
@include('user.buttons.user')
@endsection
@section('content')
@if (auth()->id() === $user->id || auth()->user()->group->is_modo)
<section class="panelV2">
<h2 class="panel__heading">{{ __('user.following') }}</h2>
<div class="data-table-wrapper">
<table class="data-table">
<thead>
<tr>
<th>{{ __('user.avatar') }}</th>
<th>{{ __('user.user') }}</th>
<th>{{ __('common.created_at') }}</th>
</tr>
</thead>
<tbody>
@forelse ($followings as $following)
<tr>
<td>
<img
src="{{ url($following->image === null ? 'img/profile.png' : 'files/img/' . $following->image) }}"
alt="{{ $following->username }}"
class="user-search__avatar"
>
</td>
<td>
<x-user_tag :anon="false" :user="$following" />
</td>
<td>{{ $following->follow->created_at }}</td>
</tr>
@empty
<tr>
<td colspan="3">Not following</td>
</tr>
@endforelse
</tbody>
</table>
</div>
{{ $followings->links('partials.pagination') }}
</section>
@else
<section class="panelV2">
<h2 class="panel__heading">{{ __('user.private-profile') }}</h2>
<div class="panel__body">{{ __('user.not-authorized') }}</div>
</section>
@endif
@endsection
+5
View File
@@ -409,6 +409,11 @@ Route::group(['middleware' => 'language'], function (): void {
Route::delete('/', [App\Http\Controllers\User\FollowController::class, 'destroy'])->name('destroy');
});
// Following
Route::group(['prefix' => 'following', 'as' => 'following.'], function (): void {
Route::get('/', [App\Http\Controllers\User\FollowingController::class, 'index'])->name('index');
});
// General settings
Route::group(['prefix' => 'general-settings', 'as' => 'general_settings.'], function (): void {
Route::get('/edit', [App\Http\Controllers\User\GeneralSettingController::class, 'edit'])->name('edit');