mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-02-09 21:19:22 -06:00
- Remove all facades use besides mail
- Use Dependency Injection for Illuminate\Http\Request
- use helpers for auth, cache, validator, and more to rid of facades use
- use $request->input() over $request->get()
- use $request->isMethod('POST') over $request->getMethod('POST')
- general cleanup
43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
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()->route('get_notifications')->with(Toastr::success('Notification Marked As Read!', 'Yay!', ['options']));
|
|
}
|
|
|
|
public function massRead()
|
|
{
|
|
$current = new Carbon();
|
|
auth()->user()->unreadNotifications()->update(['read_at' => $current]);
|
|
return redirect()->route('get_notifications')->with(Toastr::success('All Notifications Marked As Read!', 'Yay!', ['options']));
|
|
}
|
|
|
|
public function delete($id)
|
|
{
|
|
auth()->user()->notifications()->findOrFail($id)->delete();
|
|
return redirect()->route('get_notifications')->with(Toastr::success('Notification Deleted!', 'Yay!', ['options']));
|
|
}
|
|
|
|
public function deleteAll()
|
|
{
|
|
auth()->user()->notifications()->delete();
|
|
return redirect()->route('get_notifications')->with(Toastr::success('All Notifications Deleted!', 'Yay!', ['options']));
|
|
}
|
|
}
|