/
profile.blade.php
247 lines (221 loc) · 11.3 KB
/
profile.blade.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
@title("{$user->username()} ({$user->name()})")
@canonical(route('profile', $user->username()))
@extends('layouts.default')
@section('content')
<section class="bg-white">
<div
class="w-full bg-center bg-gray-800 h-60"
style="background-image: url('{{ asset('images/default-background.svg') }}')"
></div>
<div class="container mx-auto">
<div class="flex justify-center lg:justify-start">
<x-avatar :user="$user" class="-mt-24 w-48 h-48 rounded-full border-8 border-white" unlinked />
</div>
<div class="flex flex-col mt-5 p-4 lg:flex-row lg:gap-x-12">
<div class="w-full mb-10 lg:w-1/3 lg:mb-0">
<div>
<div class="flex items-center gap-x-4">
<h1 class="text-4xl font-bold">{{ $user->name() }}</h1>
@if ($user->isAdmin() || $user->isModerator())
<span class="border border-lio-500 text-lio-500 rounded px-3 py-1">
{{ $user->isAdmin() ? 'Admin' : 'Moderator' }}
</span>
@endif
</div>
<span class="text-gray-600">
Joined {{ $user->createdAt()->format('j M Y') }}
</span>
</div>
<div class="mt-4">
<span class="text-gray-900">
{{ $user->bio() }}
</span>
</div>
<div class="mt-4 mb-6 flex items-center gap-x-3">
@if ($user->githubUsername())
<a href="https://github.com/{{ $user->githubUsername() }}">
<x-icon-github class="w-6 h-6" />
</a>
@endif
@if ($user->hasTwitterAccount())
<a href="https://twitter.com/{{ $user->twitter() }}" class="text-twitter">
<x-si-x class="w-6 h-6" />
</a>
@endif
@if ($user->hasWebsite())
<a href="{{ $user->website() }}">
<x-heroicon-o-globe-alt class="w-6 h-6" />
</a>
@endif
</div>
<div class="flex flex-col gap-y-4">
@if ($user->isLoggedInUser())
<x-buttons.secondary-button href="{{ route('settings.profile') }}" class="w-full">
<span class="flex items-center gap-x-2">
<x-heroicon-o-pencil class="w-5 h-5" />
Edit profile
</span>
</x-buttons.secondary-button>
@endif
@can(App\Policies\UserPolicy::BLOCK, $user)
@if (Auth::user()->hasBlocked($user))
<x-buttons.secondary-button class="w-full" @click.prevent="activeModal = 'unblockUser'">
<span class="flex items-center gap-x-2">
<x-heroicon-o-check class="w-5 h-5" />
Unblock User
</span>
</x-buttons.secondary-button>
@else
<x-buttons.danger-button class="w-full" @click.prevent="activeModal = 'blockUser'">
<span class="flex items-center gap-x-2">
<x-heroicon-o-x-mark class="w-5 h-5" />
Block User
</span>
</x-buttons.danger-button>
@endif
@endcan
@can(App\Policies\UserPolicy::BAN, $user)
@if ($user->isBanned())
<x-buttons.secondary-button class="w-full" @click.prevent="activeModal = 'unbanUser'">
<span class="flex items-center gap-x-2">
<x-heroicon-o-check class="w-5 h-5" />
Unban User
</span>
</x-buttons.secondary-button>
@else
<x-buttons.danger-button class="w-full" @click.prevent="activeModal = 'banUser'">
<span class="flex items-center gap-x-2">
<x-icon-hammer class="w-5 h-5" />
Ban User
</span>
</x-buttons.danger-button>
@endif
@endcan
@if ($user->bannedReason())
@can(App\Policies\UserPolicy::BAN, $user)
<div class="mt-2 bg-red-100 text-sm px-4 py-3 border border-red-200 rounded shadow">
<p class="font-semibold">Banned reason:</p>
<span class="text-gray-900">
{{ $user->bannedReason() }}
</span>
</div>
@endcan
@endif
</div>
</div>
<div class="w-full lg:w-2/3">
<h2 class="text-3xl font-semibold">
Statistics
</h2>
<div class="mt-4 grid grid-cols-1 lg:grid-cols-2">
<div class="w-full flex justify-between px-5 py-2.5 bg-gray-100">
<span>Threads</span>
<span class="text-lio-500">
{{ number_format($user->countThreads()) }}
</span>
</div>
<div class="w-full flex justify-between px-5 py-2.5 bg-white lg:bg-gray-100">
<span>Replies</span>
<span class="text-lio-500">
{{ number_format($user->countReplies()) }}
</span>
</div>
<div class="w-full flex justify-between px-5 py-2.5 bg-gray-100 lg:bg-white">
<span>Solutions</span>
<span class="text-lio-500">
{{ number_format($user->countSolutions()) }}
</span>
</div>
<div class="w-full flex justify-between px-5 py-2.5">
<span>Articles</span>
<span class="text-lio-500">
{{ number_format($user->countArticles()) }}
</span>
</div>
</div>
</div>
</div>
@if ($articles->count() > 0)
<div class="mt-10 px-4 lg:mt-28">
<h2 class="text-3xl font-semibold">
Articles
</h2>
<div class="mt-8 flex flex-col gap-y-8 lg:flex-row lg:gap-x-8 lg:mb-16">
@foreach ($articles as $article)
<div class="w-full lg:w-1/3">
<x-articles.user-summary :article="$article" />
</div>
@endforeach
</div>
</div>
@endif
</div>
<div class="mt-16 lg:mt-32" x-data="{ tab: 'threads' }">
<div class="container mx-auto">
<nav class="flex items-center justify-between lg:justify-start">
<button @click="tab = 'threads'" :class="{ 'text-lio-500 border-lio-500 border-b-2': tab === 'threads' }" class="px-4 whitespace-nowrap py-5 font-medium text-lg text-gray-900 hover:text-lio-500 hover:border-lio-500 focus:outline-none focus:text-lio-500 focus:border-lio-500 lg:w-1/3">
Threads posted
</button>
<button @click="tab = 'replies'" :class="{ 'text-lio-500 border-lio-500 border-b-2': tab === 'replies' }" class="px-4 whitespace-nowrap py-5 font-medium text-lg text-gray-900 hover:text-lio-500 hover:border-lio-500 focus:outline-none focus:text-lio-500 focus:border-lio-500 lg:w-1/3">
Replies posted
</button>
</nav>
</div>
<div class="bg-gray-100 py-14 px-4">
<div class="container mx-auto">
<div x-show="tab === 'threads'">
@include('users._latest_threads')
</div>
<div x-show="tab === 'replies'" x-cloak>
@include('users._latest_replies')
</div>
</div>
</div>
</div>
</section>
@can(App\Policies\UserPolicy::BLOCK, $user)
@if (Auth::user()->hasBlocked($user))
<x-modal
identifier="unblockUser"
:action="route('users.unblock', $user->username())"
title="Unblock {{ $user->username() }}"
type="update"
>
<p>Unblocking this user will allow them to mention you again in threads and replies.</p>
</x-modal>
@else
<x-modal
identifier="blockUser"
:action="route('users.block', $user->username())"
title="Block {{ $user->username() }}"
type="update"
>
<p>Blocking this user will prevent them from mentioning you in threads and replies. The user will not be notified that you blocked them.</p>
</x-modal>
@endif
@endcan
@can(App\Policies\UserPolicy::BAN, $user)
@if ($user->isBanned())
<x-modal
identifier="unbanUser"
:action="route('admin.users.unban', $user->username())"
title="Unban {{ $user->username() }}"
type="update"
>
<p>Unbanning this user will allow them to login again and post content.</p>
</x-modal>
@else
<x-modal
identifier="banUser"
:action="route('admin.users.ban', $user->username())"
title="Ban {{ $user->username() }}"
type="update"
>
<p>Banning this user will prevent them from logging in, posting threads and replying to threads.</p>
<div class="mt-4">
<x-forms.inputs.textarea name="reason" placeholder="Provide a reason for banning this user..." required />
</div>
</x-modal>
@endif
@endcan
@endsection