-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bf0ec22
commit c17432a
Showing
9 changed files
with
131 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Auth; | ||
|
||
class NotificationsController extends Controller | ||
{ | ||
public function __construct() | ||
{ | ||
$this->middleware('auth'); | ||
} | ||
|
||
public function index() | ||
{ | ||
// 获取登录用户的所有通知 | ||
$notifications = Auth::user()->notifications()->paginate(20); | ||
// 标记为已读,未读数量清零 | ||
Auth::user()->markAsRead(); | ||
return view('notifications.index', compact('notifications')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
@extends('layouts.app') | ||
|
||
@section('title', '我的通知') | ||
|
||
@section('content') | ||
<div class="container"> | ||
<div class="col-md-10 offset-md-1"> | ||
<div class="card "> | ||
|
||
<div class="card-body"> | ||
|
||
<h3 class="text-xs-center"> | ||
<i class="far fa-bell" aria-hidden="true"></i> 我的通知 | ||
</h3> | ||
<hr> | ||
|
||
@if ($notifications->count()) | ||
|
||
<div class="list-unstyled notification-list"> | ||
@foreach ($notifications as $notification) | ||
@include('notifications.types._' . Str::snake(class_basename($notification->type))) | ||
@endforeach | ||
|
||
{!! $notifications->render() !!} | ||
</div> | ||
|
||
@else | ||
<div class="empty-block">没有消息通知!</div> | ||
@endif | ||
|
||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
@stop |
24 changes: 24 additions & 0 deletions
24
resources/views/notifications/types/_topic_replied.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<li class="d-flex @if ( ! $loop->last) border-bottom @endif"> | ||
<div> | ||
<a href="{{ route('users.show', $notification->data['user_id']) }}"> | ||
<img class="img-thumbnail mr-3" alt="{{ $notification->data['user_name'] }}" src="{{ $notification->data['user_avatar'] }}" style="width:48px;height:48px;" /> | ||
</a> | ||
</div> | ||
|
||
<div class="flex-grow-1 ms-2"> | ||
<div class="mt-0 mb-1 text-secondary"> | ||
<a class="text-decoration-none" href="{{ route('users.show', $notification->data['user_id']) }}">{{ $notification->data['user_name'] }}</a> | ||
评论了 | ||
<a class="text-decoration-none" href="{{ $notification->data['topic_link'] }}">{{ $notification->data['topic_title'] }}</a> | ||
|
||
{{-- 回复删除按钮 --}} | ||
<span class="meta float-end" title="{{ $notification->created_at }}"> | ||
<i class="far fa-clock"></i> | ||
{{ $notification->created_at->diffForHumans() }} | ||
</span> | ||
</div> | ||
<div class="reply-content"> | ||
{!! $notification->data['reply_content'] !!} | ||
</div> | ||
</div> | ||
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters