Create NotificationController and display bell icon in navigation for notifications
ADD
app/Http/Controllers/NotificationController.php
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Http\Request;
+
+class NotificationController extends Controller {
+ public function index() {
+ return view('notifications.index', [
+ 'notifications' => session('space')->notifications()->latest()->get()
+ ]);
+ }
+}

MODIFY
app/Http/Middleware/RefreshSpaceRelations.php
app/Http/Middleware/RefreshSpaceRelations.php
@@ -7,7 +7,7 @@ use Closure;
class RefreshSpaceRelations {
public function handle($request, Closure $next) {
if ($request->session()->has('space')) {
- $request->session()->get('space')->load('tags', 'earnings', 'spendings', 'recurrings');
+ $request->session()->get('space')->load('tags', 'earnings', 'spendings', 'recurrings', 'notifications');
}
return $next($request);

ADD
resources/lang/en/notifications.php
+<?php
+
+return [
+ 'transaction' => [
+ 'created' => 'Created Transaction',
+ 'modified' => 'Modified Transaction',
+ 'deleted' => 'Deleted Transaction'
+ ],
+
+ 'tag' => [
+ 'created' => 'Created Tag',
+ 'modified' => 'Modified Tag',
+ 'deleted' => 'Deleted Tag'
+ ]
+];

MODIFY
resources/views/layout.blade.php
resources/views/layout.blade.php
<li>
<a href="/transactions/create" class="button" style="font-size: 12px; color: #FFF; padding: 5px 10px;">Create Transaction</a>
</li>
+ <li>
+ <a href="/notifications">
+ <i class="fas fa-bell"></i>
+ </a>
+ </li>
@if (Auth::user()->spaces->count() > 1)
<li>
<dropdown>

ADD
resources/views/notifications/index.blade.php
+@extends('layout')
+
+@section('title', 'Notifications')
+
+@section('body')
+ <div class="wrapper my-3">
+ <h2>Notifications</h2>
+ <div class="box mt-3">
+ @foreach ($notifications as $notification)
+ <div class="box__section row">
+ <div class="row__column">{{ __('notifications.' . $notification->action) }}</div>
+ <div class="row__column">{{ $notification->created_at }}</div>
+ </div>
+ @endforeach
+ </div>
+ </div>
+@endsection

MODIFY
routes/web.php
routes/web.php
@@ -66,6 +66,10 @@ Route::group(['middleware' => ['auth']], function () {
Route::delete('/imports/{import}', 'ImportController@destroy');
});
+ Route::name('notifications.')->group(function () {
+ Route::get('/notifications', 'NotificationController@index')->name('index');
+ });
+
Route::name('settings.')->group(function () {
Route::get('/settings', 'SettingsController@getIndex')->name('index');
Route::post('/settings', 'SettingsController@postIndex');

Create NotificationController and display bell icon in navigation for notifications