Answer the question
In order to leave comments, you need to log in
In what other way, you can display notifications?
I send out notifications. Data is added to the notifications
table in the date, in this way
public function toDatabase($notifiable) {
return [
'post_id' => $this->details['post_id'], // id поста
'comment_id' => $this->details['comment_id'], //id комента
'user_comment_id' => $this->details['user_comment_id'] // id юзера, который оставил коммент
];
public function readNotification()
{
$user = User::find(Auth::id());
$allData = collect();
foreach ($user->unreadNotifications as $notification) {
$collect1 = collect(Post::find($notification->data['post_id']));
$collect2 = collect(['user_comment' => Comment::find($notification->data['comment_id'])->text]);
$collect3 = collect(['user_name' => User::find($notification->data['user_comment_id'])->name]);
$allData->push($collect1
->merge($collect2)
->merge($collect3)
->merge(['id_notif' => $notification->id]));
}
return view('read-notifications', [
'allData' => $allData,
]);
}
<section class="section main-content">
<div class="container">
@foreach ($allData as $data)
<div class="card">
<div class="card-body">
<h5 class="card-title">{{$data['user_name']}}, добавил комментраий к посту - {{$data['description']}}</h5>
<div class="card-text">{!!$data['user_comment']!!}</div>
<br>
<a href="/post/{{$data['id']}}" class="btn btn-primary">Перейти</a>
<a href="/mark-notif-read/{{$data['id_notif']}}" class="btn btn-primary">Отменить прочитанным</a>
</div>
</div>
<br>
@endforeach
</div>
</section>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question