mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-05-05 10:11:25 -05:00
(Update) Finish Notifications System
- Can delete notifications - Can mark single notification as read - Can mass update all notifications as read - Notification Title links to source
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Notifications;
|
||||
use \Toastr;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class NotificationController extends Controller
|
||||
{
|
||||
public function get() {
|
||||
$notification = Auth::user()->notifications;
|
||||
return view('notification.notifications', ['notification' => $notification]);
|
||||
}
|
||||
|
||||
public function read($id) {
|
||||
Auth::user()->unreadNotifications()->findOrFail($id)->markAsRead();
|
||||
return Redirect::back()->with(Toastr::success('Notification Marked As Read!', 'Yay!', ['options']));
|
||||
}
|
||||
|
||||
public function massRead() {
|
||||
$current = new Carbon();
|
||||
Auth::user()->unreadNotifications()->update(['read_at' => $current]);
|
||||
return Redirect::back()->with(Toastr::success('All Notifications Marked As Read!', 'Yay!', ['options']));
|
||||
}
|
||||
|
||||
public function delete($id) {
|
||||
Auth::user()->notifications()->findOrFail($id)->delete();
|
||||
return Redirect::back()->with(Toastr::success('Notification Deleted!', 'Yay!', ['options']));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user