Skip to content

Commit 8a4c542

Browse files
authored
Merge pull request #3 from devaslanphp/dev
Add mentions to reply rich editor
2 parents 003d5bb + aea3b6d commit 8a4c542

File tree

7 files changed

+5184
-1189
lines changed

7 files changed

+5184
-1189
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace App\Forms\Components;
4+
5+
use Filament\Forms\Components\RichEditor;
6+
7+
class MentionsRichEditor extends RichEditor
8+
{
9+
protected string $view = 'forms.components.mentions-rich-editor';
10+
11+
protected array $mentionsItems = [];
12+
13+
public function mentionsItems(array $mentionsItems): static
14+
{
15+
$this->mentionsItems = $mentionsItems;
16+
17+
return $this;
18+
}
19+
20+
public function getMentionsItems(): array
21+
{
22+
return $this->mentionsItems;
23+
}
24+
}

app/Http/Livewire/Discussion/Reply.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@
44

55
use App\Core\NotificationConstants;
66
use App\Core\PointsConstants;
7+
use App\Forms\Components\MentionsRichEditor;
78
use App\Jobs\CalculateUserPointsJob;
89
use App\Jobs\DispatchNotificationsJob;
910
use App\Models\Discussion;
1011
use App\Models\Reply as ReplyModel;
12+
use App\Models\User;
1113
use Filament\Facades\Filament;
1214
use Filament\Forms\Components\RichEditor;
1315
use Filament\Forms\Concerns\InteractsWithForms;
1416
use Filament\Forms\Contracts\HasForms;
17+
use Illuminate\Support\Str;
1518
use Livewire\Component;
1619

1720
class Reply extends Component implements HasForms
@@ -38,8 +41,20 @@ public function render()
3841
protected function getFormSchema(): array
3942
{
4043
return [
41-
RichEditor::make('content')
44+
MentionsRichEditor::make('content')
4245
->label('Reply content')
46+
->mentionsItems(
47+
User::all()
48+
->map(
49+
fn (User $user) => [
50+
'key' => $user->name,
51+
'link' => route('user.index', [
52+
'user' => $user,
53+
'slug' => Str::slug($user->name)
54+
])
55+
])
56+
->toArray()
57+
)
4358
->required()
4459
];
4560
}

0 commit comments

Comments
 (0)