turtle-wow-source-kinda/Dumps/Source Code/8 - Development_website/develop/app/Livewire/EditComment.php
Brian Oost a1d5bb70b2 Init
2024-08-06 18:06:40 +02:00

53 lines
1.2 KiB
PHP

<?php
namespace App\Livewire;
use App\Models\BugTrackerMessage;
use Illuminate\Support\Facades\Auth;
use Livewire\Component;
class EditComment extends Component
{
protected $listeners = [
'openModal'
];
public $commentId;
public $commentText;
public function openModal($commentId)
{
$this->commentId = $commentId;
$comment = BugTrackerMessage::find($this->commentId);
$this->commentText = $comment->message;
}
public function save()
{
$user = Auth::guard('account')->user();
if ($user->latestBan()?->active == 1) {
$this->bug_tracker_responseMessage = 'You are banned.';
return;
}
$comment = BugTrackerMessage::find($this->commentId);
if ($user->rank < 2 && $comment->account_id != $user->id) {
return;
}
$comment->message = $this->commentText;
$comment->save();
$this->dispatch('updateHistoryBugReport', type: 'editComment');
$this->redirect(route('bug-report', ['id' => $comment->bug_tracker_id]));
}
public function render()
{
return view('livewire.edit-comment');
}
}