Skip to content

Commit e84a5c7

Browse files
authored
🐛 fix user model not found (#94)
1 parent e6e205a commit e84a5c7

File tree

13 files changed

+858
-817
lines changed

13 files changed

+858
-817
lines changed

app/Http/Livewire/Discussions/Comments.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function getCommentsProperty(): Collection
2828
{
2929
$replies = collect();
3030

31-
foreach ($this->discussion->replies->load(['allChildReplies', 'author']) as $reply) {
31+
foreach ($this->discussion->replies->load(['allChildReplies', 'user']) as $reply) {
3232
/** @var Reply $reply */
3333
if ($reply->allChildReplies->isNotEmpty()) {
3434
foreach ($reply->allChildReplies as $childReply) {

app/Http/Livewire/MarkdownX.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,11 @@ public function getTrendingPeoples(array $payload): void
247247
->get()
248248
->map(
249249
function (User $user) {
250-
$people['name'] = $user->name;
251-
$people['picture'] = $user->profile_photo_url;
252-
$people['username'] = $user->username;
253-
return $people;
254-
}
250+
$people['name'] = $user->name;
251+
$people['picture'] = $user->profile_photo_url;
252+
$people['username'] = $user->username;
253+
return $people;
254+
}
255255
);
256256

257257
$this->dispatchBrowserEvent('markdown-x-peoples-results', [

app/Http/Middleware/HttpsProtocol.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
namespace App\Http\Middleware;
66

77
use Closure;
8+
use Illuminate\Http\JsonResponse;
89
use Illuminate\Http\RedirectResponse;
910
use Illuminate\Http\Request;
11+
use Illuminate\Http\Response;
1012

1113
class HttpsProtocol
1214
{
13-
public function handle(Request $request, Closure $next): RedirectResponse
15+
public function handle(Request $request, Closure $next): RedirectResponse | Response | JsonResponse
1416
{
1517
if (app()->environment('production') && ! $request->isSecure()) {
1618
return redirect()->secure($request->getRequestUri());

app/Listeners/SendNewCommentNotification.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace App\Listeners;
66

77
use App\Events\CommentWasAdded;
8-
use App\Models\Discussion;
98
use App\Models\Subscribe;
109
use App\Models\User;
1110
use App\Notifications\NewCommentNotification;

helpers/ModelHelper.php

Lines changed: 782 additions & 748 deletions
Large diffs are not rendered by default.

resources/views/components/forum/thread.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ class="origin-top-right absolute right-0 mt-2 w-56 rounded-md shadow-lg bg-skin-
4949
@can(App\Policies\ThreadPolicy::DELETE, $thread)
5050
<button type="button" onclick="Livewire.emit('openModal', 'modals.delete-thread', {{ json_encode([$thread->id]) }})" class="group text-skin-inverted-muted flex px-4 py-2 text-sm hover:text-skin-inverted" role="menuitem" tabindex="-1">
5151
<x-heroicon-s-trash class="mr-3 h-5 w-5 text-skin-muted group-hover:text-skin-base" />
52-
<span>Supprimer</span>
52+
<span>{{ __('Supprimer') }}</span>
5353
</button>
5454
@endcan
5555
<a href="#" class="group text-skin-inverted-muted flex px-4 py-2 text-sm hover:text-skin-inverted" role="menuitem" tabindex="-1">
5656
<x-heroicon-s-flag class="mr-3 h-5 w-5 text-skin-muted group-hover:text-skin-base" />
57-
<span>Signaler contenu</span>
57+
<span>{{ __('Signaler contenu') }}</span>
5858
</a>
5959
</div>
6060
</div>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<span class="ml-2 inline-flex items-center px-2.5 py-0.5 rounded-md text-sm font-medium bg-green-500 bg-opacity-10 text-green-500 font-sans">
2-
Modérateur
2+
{{ __('Modérateur') }}
33
</span>

resources/views/discussions/_contributions.blade.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,19 @@
4444
@foreach($discussions as $discussion)
4545
<li class="py-4">
4646
<div class="flex space-x-3">
47-
<img class="h-6 w-6 object-cover rounded-full" src="{{ $discussion->author->profile_photo_url }}" alt="">
47+
<img class="h-6 w-6 object-cover rounded-full" src="{{ $discussion->user->profile_photo_url }}" alt="">
4848
<div class="flex-1 space-y-1">
4949
<div class="flex items-center justify-between">
5050
<h3 class="text-sm font-medium text-skin-inverted font-sans">
51-
<a href="{{ route('profile', $discussion->author->username) }}" class="hover:underline">{{ $discussion->author->name }}</a>
51+
<a href="{{ route('profile', $discussion->user->username) }}" class="hover:underline">{{ $discussion->user->name }}</a>
5252
</h3>
53-
<p class="text-xs text-skin-muted font-normal truncate"><time-ago time="{{ $discussion->created_at->getTimestamp() }}" /></p>
53+
<p class="text-xs text-skin-muted font-normal truncate">
54+
<time-ago time="{{ $discussion->created_at->getTimestamp() }}" />
55+
</p>
5456
</div>
55-
<a href="{{ route('discussions.show', $discussion) }}" class="inline-flex text-sm text-skin-base font-normal hover:text-skin-inverted leading-5">{{ $discussion->title }}</a>
57+
<a href="{{ route('discussions.show', $discussion) }}" class="inline-flex text-sm text-skin-base font-normal hover:text-skin-inverted leading-5">
58+
{{ $discussion->title }}
59+
</a>
5660
</div>
5761
</div>
5862
</li>

resources/views/discussions/show.blade.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@
2626
<div class="relative sm:flex sm:space-x-3">
2727
<div class="flex items-center sm:items-start">
2828
<div class="relative">
29-
<img class="h-10 w-10 object-cover rounded-full bg-skin-card-gray ring-8 ring-body" src="{{ $discussion->author->profile_photo_url }}" alt="{{ $discussion->author->name }}">
29+
<img class="h-10 w-10 object-cover rounded-full bg-skin-card-gray ring-8 ring-body" src="{{ $discussion->user->profile_photo_url }}" alt="{{ $discussion->user->name }}">
3030
<span class="absolute top-5 -right-1 bg-skin-body rounded-tl px-0.5 py-px">
3131
<svg class="h-5 w-5 text-skin-muted" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
3232
<path fill-rule="evenodd" d="M12 2.25c-2.429 0-4.817.178-7.152.521C2.87 3.061 1.5 4.795 1.5 6.741v6.018c0 1.946 1.37 3.68 3.348 3.97.877.129 1.761.234 2.652.316V21a.75.75 0 001.28.53l4.184-4.183a.39.39 0 01.266-.112c2.006-.05 3.982-.22 5.922-.506 1.978-.29 3.348-2.023 3.348-3.97V6.741c0-1.947-1.37-3.68-3.348-3.97A49.145 49.145 0 0012 2.25zM8.25 8.625a1.125 1.125 0 100 2.25 1.125 1.125 0 000-2.25zm2.625 1.125a1.125 1.125 0 112.25 0 1.125 1.125 0 01-2.25 0zm4.875-1.125a1.125 1.125 0 100 2.25 1.125 1.125 0 000-2.25z" clip-rule="evenodd" />
3333
</svg>
3434
</span>
3535
</div>
3636
<div class="ml-4 sm:hidden">
37-
<a href="{{ route('profile', $discussion->author->username) }}">
37+
<a href="{{ route('profile', $discussion->user->username) }}">
3838
<h4 class="inline-flex items-center text-sm text-skin-inverted font-medium">
39-
{{ $discussion->author->name }}
40-
@if($discussion->author->hasAnyRole('admin', 'moderator'))
39+
{{ $discussion->user->name }}
40+
@if($discussion->user->hasAnyRole('admin', 'moderator'))
4141
<x-user.status />
4242
@endif
4343
</h4>
@@ -50,17 +50,19 @@
5050
</div>
5151
<div class="min-w-0 flex-1">
5252
<div class="hidden sm:block">
53-
<a href="{{ route('profile', $discussion->author->username) }}">
53+
<a href="{{ route('profile', $discussion->user->username) }}">
5454
<h4 class="inline-flex items-center text-sm text-skin-inverted font-medium">
55-
{{ $discussion->author->name }}
56-
@if($discussion->author->hasAnyRole('admin', 'moderator'))
55+
{{ $discussion->user->name }}
56+
@if($discussion->user->hasAnyRole('admin', 'moderator'))
5757
<x-user.status />
5858
@endif
5959
</h4>
6060
</a>
6161
<div class="text-sm whitespace-nowrap text-skin-muted font-normal">
62-
<time class="sr-only" datetime="{{ $discussion->created_at->format('Y-m-d') }}">{{ $discussion->created_at->diffForHumans() }}</time>
63-
Crée <time-ago time="{{ $discussion->created_at->getTimestamp() }}"/>
62+
<time class="sr-only" datetime="{{ $discussion->created_at->format('Y-m-d') }}">
63+
{{ $discussion->created_at->diffForHumans() }}
64+
</time>
65+
{{ __('Crée') }} <time-ago time="{{ $discussion->created_at->getTimestamp() }}"/>
6466
</div>
6567
</div>
6668
<x-markdown-content class="mt-3 text-sm prose md:prose-lg prose-green text-skin-base mx-auto max-w-none" :content="$discussion->body" />

resources/views/forum/thread.blade.php

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@
99
<div class="hidden relative lg:block lg:col-span-2">
1010
<x-sticky-content class="space-y-6">
1111
<x-button :link="route('forum.new')" class="w-full flex justify-center">
12-
Nouveau Sujet
12+
{{ __('Nouveau Sujet') }}
1313
<x-heroicon-o-plus-circle class="h-4 w-4 ml-2.5" />
1414
</x-button>
1515
<nav>
1616
<a href="{{ route('forum.index') }}" class="w-full inline-flex items-center text-skin-base hover:text-skin-inverted py-3 text-sm font-medium">
1717
<x-heroicon-s-menu class="h-5 w-5 mr-2" />
18-
<span>Tous les sujets</span>
18+
<span>{{ __('Tous les sujets') }}</span>
1919
</a>
2020
</nav>
2121

2222
@auth
2323
<livewire:forum.subscribe :thread="$thread" />
2424
@endauth
2525

26-
<x-forum.thread-author :author="$thread->author" />
26+
<x-forum.thread-author :author="$thread->user" />
2727
</x-sticky-content>
2828
</div>
2929
<div class="lg:col-span-7 lg:pl-8 lg:border-l lg:border-skin-base">
@@ -32,17 +32,17 @@
3232
<div class="border-b pt-2 pb-4 border-skin-base">
3333
<div class="sm:inline-flex sm:items-center text-sm text-skin-inverted-muted">
3434
<div class="flex items-center">
35-
<a href="{{ route('profile', $thread->author->username) }}" class="inline-flex items-center hover:underline">
36-
<img class="inline-block rounded-full h-5 w-5 mr-1" src="{{ $thread->author->profile_photo_url }}" alt="Avatar de {{ $thread->author->username }}">
37-
<span class="font-sans">{{ '@' . $thread->author->username }}</span>
35+
<a href="{{ route('profile', $thread->user->username) }}" class="inline-flex items-center hover:underline">
36+
<img class="inline-block rounded-full h-5 w-5 mr-1" src="{{ $thread->user->profile_photo_url }}" alt="Avatar de {{ $thread->user->username }}">
37+
<span class="font-sans">{{ '@' . $thread->user->username }}</span>
3838
</a>
39-
<x-user.points :author="$thread->author" />
39+
<x-user.points :author="$thread->user" />
4040
<span class="inline-flex mx-1.5 space-x-1">
41-
<span>a posé</span>
41+
<span>{{ __('a posé') }}</span>
4242
<time-ago time="{{ $thread->created_at->getTimestamp() }}"/>
4343
<time class="sr-only" datetime="{{ $thread->created_at }}" title="{{ $thread->last_posted_at->format('j M, Y \à H:i') }}">{{ $thread->last_posted_at->format('j M, Y \à H:i') }}</time>
4444
</span>
45-
<span>dans</span>
45+
<span>{{ __('dans') }}</span>
4646
</div>
4747
<div class="mt-2 sm:mt-0 sm:ml-2 self-center flex items-center space-x-2">
4848
<div class="shrink-0">
@@ -61,7 +61,7 @@
6161
<span class="text-skin-muted mx-2">•</span>
6262
<span class="inline-flex items-center gap-x-2 font-medium text-green-500">
6363
<x-heroicon-s-badge-check class="w-5 h-5" />
64-
<span>Résolu</span>
64+
<span>{{ __('Résolu') }}</span>
6565
</span>
6666
</div>
6767
@endif
@@ -87,11 +87,11 @@
8787
@if ($thread->isConversationOld())
8888
<x-info-panel class="font-sans">
8989
<p class="text-sm text-blue-700">
90-
La dernière réponse à ce sujet remonte à plus de six mois. Pensez à ouvrir un nouveau sujet si vous avez une question similaire.
90+
{{ __('La dernière réponse à ce sujet remonte à plus de six mois. Pensez à ouvrir un nouveau sujet si vous avez une question similaire.') }}
9191
</p>
9292
<p class="mt-4 text-sm">
9393
<a href="{{ route('forum.new') }}" class="whitespace-nowrap bg-blue-100 rounded-md px-3 py-2 border border-transparent font-medium text-blue-700 hover:text-blue-600 focus:ring-2 focus:ring-offset-2 focus:ring-offset-blue-50 focus:ring-blue-600">
94-
Créer un nouveau sujet <span aria-hidden="true">&rarr;</span>
94+
{{ __('Créer un nouveau sujet') }} <span aria-hidden="true">&rarr;</span>
9595
</a>
9696
</p>
9797
</x-info-panel>
@@ -103,16 +103,18 @@
103103
@else
104104
@guest
105105
<p class="text-center py-8 font-sans text-skin-base">
106-
Veuillez vous <a href="{{ route('login') }}" class="text-skin-primary hover:text-skin-primary-hover hover:underline">connecter</a> ou <a href="{{ route('register') }}" class="text-skin-primary hover:text-skin-primary-hover hover:underline">créer un compte</a> pour participer à cette conversation.
106+
{{ __('Veuillez vous') }} <a href="{{ route('login') }}" class="text-skin-primary hover:text-skin-primary-hover hover:underline">{{ __('connecter') }}</a> {{ __('ou') }}
107+
<a href="{{ route('register') }}" class="text-skin-primary hover:text-skin-primary-hover hover:underline">{{ __('créer un compte') }}</a>
108+
{{ __('pour participer à cette conversation.') }}
107109
</p>
108110
@else
109111
<div class="mt-10 flex justify-between items-center gap-x-12 text-skin-base">
110-
<p>Vous devrez vérifier votre compte avant de participer à cette conversation.</p>
112+
<p>{{ __('Vous devrez vérifier votre compte avant de participer à cette conversation.') }}</p>
111113

112114
<form action="{{ route('verification.send') }}" method="POST" class="block">
113115
@csrf
114116
<x-button type="submit" class="px-3 py-2 text-sm leading-4">
115-
Recevoir un lien
117+
{{ __('Recevoir un lien') }}
116118
<x-heroicon-o-arrow-narrow-right class="h-5 w-5 ml-1.5" />
117119
</x-button>
118120
</form>

resources/views/livewire/discussions/browse.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class="relative lg:col-span-7"
3232
aria-current="{{ $selectedSortBy === 'recent' ? 'page' : 'false' }}"
3333
class="w-full {{ $selectedSortBy === 'recent' ? 'text-skin-inverted': 'text-skin-base hover:text-skin-inverted' }} rounded-l-lg group relative min-w-0 flex-1 overflow-hidden bg-skin-card py-4 px-6 text-sm font-medium text-center hover:bg-skin-card-muted focus:z-10"
3434
>
35-
<span>Récent</span>
35+
<span>{{ __('Récent') }}</span>
3636
<span aria-hidden="true" class="{{ $selectedSortBy === 'recent' ? 'bg-skin-primary': 'bg-transparent' }} absolute inset-x-0 bottom-0 h-0.5"></span>
3737
</button>
3838

0 commit comments

Comments
 (0)