This commit is contained in:
2026-04-18 14:18:52 +02:00
parent 5b4d3d435e
commit f3e5100d5d
126 changed files with 743 additions and 795 deletions

View File

@@ -2,11 +2,10 @@
namespace App\Livewire;
use Illuminate\Support\Facades\RateLimiter;
use Livewire\Component;
use Livewire\WithPagination;
use Illuminate\Support\Facades\RateLimiter;
class Comments extends Component
{
use WithPagination;
@@ -14,21 +13,21 @@ class Comments extends Component
public $model;
public $newCommentState = [
'body' => ''
'body' => '',
];
protected $validationAttributes = [
'newCommentState.body' => 'comment'
'newCommentState.body' => 'comment',
];
protected $listeners = [
'refresh' => '$refresh'
'refresh' => '$refresh',
];
public function postComment()
{
$this->validate([
'newCommentState.body' => 'required'
'newCommentState.body' => 'required',
]);
$user = auth()->user();
@@ -39,6 +38,7 @@ class Comments extends Component
$seconds = RateLimiter::availableIn($rateLimitKey);
$this->addError('newCommentState.body', "Too many comments. Try again in {$seconds} seconds.");
return;
}
@@ -49,7 +49,7 @@ class Comments extends Component
$comment->save();
$this->newCommentState = [
'body' => ''
'body' => '',
];
$this->resetPage();
@@ -65,7 +65,7 @@ class Comments extends Component
->paginate(50);
return view('livewire.comments', [
'comments' => $comments
'comments' => $comments,
]);
}
}
}