mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-01-21 03:21:38 -06:00
The Laravel framework adopts the PSR-2 coding style in version 5.1. Laravel apps *should* adopt this coding style as well. Read the [PSR-2 coding style guide][1] for more details and check out [PHPCS][2] to use as a code formatting tool. [1]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md [2]: https://github.com/squizlabs/PHP_CodeSniffer
39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?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']));
|
|
}
|
|
}
|