Skip to content

Commit ebe5194

Browse files
feat: [LAR-131] update locale selector (#256)
Co-authored-by: Chris Samory <[email protected]>
1 parent 38766e1 commit ebe5194

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+202
-110
lines changed

app/Actions/Discussion/ConvertDiscussionToThreadAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function execute(Discussion $discussion): Thread
2828

2929
$discussion->delete();
3030

31-
app(NotifyUsersOfThreadConversion::class)->execute($thread);
31+
app(NotifyUsersOfThreadConversionAction::class)->execute($thread);
3232

3333
return $thread;
3434
});

app/Actions/Replies/CreateReply.php renamed to app/Actions/Discussion/CreateDiscussionReplyAction.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
declare(strict_types=1);
44

5-
namespace App\Actions\Replies;
5+
namespace App\Actions\Discussion;
66

77
use App\Events\CommentWasAdded;
88
use App\Gamify\Points\ReplyCreated;
99
use App\Models\Reply;
1010
use App\Models\User;
1111
use Illuminate\Database\Eloquent\Model;
1212

13-
final class CreateReply
13+
final class CreateDiscussionReplyAction
1414
{
1515
public function __invoke(string $body, User $user, Model $model): Reply
1616
{
@@ -22,7 +22,7 @@ public function __invoke(string $body, User $user, Model $model): Reply
2222
$user->givePoint(new ReplyCreated($model, $user));
2323

2424
// On envoie un event pour une nouvelle réponse à tous les abonnés de la discussion
25-
event(new CommentWasAdded($reply, $model)); // @phpstan-ignore-line
25+
event(new CommentWasAdded($reply, $model)); // @phpstan-ignore-line
2626

2727
return $reply;
2828
}

app/Actions/Replies/LikeReply.php renamed to app/Actions/Discussion/LikeReplyAction.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
declare(strict_types=1);
44

5-
namespace App\Actions\Replies;
5+
namespace App\Actions\Discussion;
66

77
use App\Models\Reaction;
88
use App\Models\Reply;
99
use App\Models\User;
1010

11-
final class LikeReply
11+
final class LikeReplyAction
1212
{
1313
public function __invoke(User $user, Reply $reply, string $reaction = 'love'): void
1414
{

app/Actions/Discussion/NotifyUsersOfThreadConversion.php renamed to app/Actions/Discussion/NotifyUsersOfThreadConversionAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use App\Notifications\ThreadConvertedByCreator;
1111
use Illuminate\Support\Facades\Auth;
1212

13-
final class NotifyUsersOfThreadConversion
13+
final class NotifyUsersOfThreadConversionAction
1414
{
1515
public function execute(Thread $thread): void
1616
{

app/Http/Controllers/SubscriptionController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function unsubscribe(Subscribe $subscription): RedirectResponse
1818

1919
session()->flash('status', __('Vous êtes maintenant désabonné de ce sujet.'));
2020

21-
return redirect()->route('forum.show', $thread->slug());
21+
return redirect()->route('forum.show', $thread->slug);
2222
}
2323

2424
public function redirect(int $id, string $type): RedirectResponse

app/Livewire/Components/ChangeLocale.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use Illuminate\Contracts\View\View;
88
use Illuminate\Support\Facades\Auth;
9-
use Illuminate\Support\Pluralizer;
109
use Livewire\Attributes\Computed;
1110
use Livewire\Component;
1211

@@ -31,9 +30,7 @@ public function changeLocale(): void
3130
app()->setLocale($locale);
3231
session()->put('locale', $locale);
3332

34-
Pluralizer::useLanguage($this->currentLocale === 'fr' ? 'french' : 'english');
35-
36-
$this->redirectRoute('home', navigate: true);
33+
$this->redirect(url()->previous(), navigate: true);
3734
}
3835

3936
#[Computed]

app/Livewire/Components/Discussion/Comment.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace App\Livewire\Components\Discussion;
66

7-
use App\Actions\Replies\LikeReply;
7+
use App\Actions\Discussion\LikeReplyAction;
88
use App\Models\Reply;
99
use Filament\Notifications\Notification;
1010
use Illuminate\Contracts\View\View;
@@ -32,7 +32,7 @@ public function toggleLike(): void
3232
{
3333
$this->authorize('like', $this->comment);
3434

35-
app()->call(LikeReply::class, [
35+
app()->call(LikeReplyAction::class, [
3636
'user' => auth()->user(),
3737
'reply' => $this->comment,
3838
]);

app/Livewire/Components/Discussion/Comments.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace App\Livewire\Components\Discussion;
66

7-
use App\Actions\Replies\CreateReply;
7+
use App\Actions\Discussion\CreateDiscussionReplyAction;
88
use App\Models\Discussion;
99
use App\Models\Reply;
1010
use Filament\Forms;
@@ -52,7 +52,7 @@ public function save(): void
5252
{
5353
$this->validate();
5454

55-
app()->call(CreateReply::class, [
55+
app()->call(CreateDiscussionReplyAction::class, [
5656
'body' => data_get($this->form->getState(), 'body'),
5757
'user' => Auth::user(),
5858
'model' => $this->discussion,

app/Livewire/Components/Slideovers/ArticleForm.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,18 @@ public function form(Form $form): Form
119119
Forms\Components\Group::make()
120120
->schema([
121121
Forms\Components\MarkdownEditor::make('body')
122+
->toolbarButtons([
123+
'attachFiles',
124+
'blockquote',
125+
'bold',
126+
'bulletList',
127+
'codeBlock',
128+
'italic',
129+
'link',
130+
'orderedList',
131+
'strike',
132+
'table',
133+
])
122134
->label(__('validation.attributes.content'))
123135
->fileAttachmentsDisk('public')
124136
->minLength(10)

app/Livewire/Pages/Articles/Index.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,30 @@
77
use App\Models\Article;
88
use App\Models\Tag;
99
use App\Traits\WithInfiniteScroll;
10+
use App\Traits\WithLocale;
1011
use Illuminate\Contracts\View\View;
1112
use Livewire\Component;
1213

1314
final class Index extends Component
1415
{
1516
use WithInfiniteScroll;
17+
use WithLocale;
18+
19+
public function mount(): void
20+
{
21+
$this->locale = config('app.locale');
22+
}
1623

1724
public function render(): View
1825
{
1926
return view('livewire.pages.articles.index', [
20-
'articles' => Article::with(['tags', 'user', 'user.transactions'])
27+
'articles' => Article::with(['tags', 'user', 'user.transactions']) // @phpstan-ignore-line
2128
->withCount(['views', 'reactions'])
2229
->orderByDesc('sponsored_at')
2330
->orderByDesc('published_at')
2431
->published()
2532
->notPinned()
33+
->forLocale($this->locale)
2634
->paginate($this->perPage),
2735
'tags' => Tag::query()->whereHas('articles', function ($query): void {
2836
$query->published();

0 commit comments

Comments
 (0)