Files
UNIT3D-Community-Edition/app/Http/Controllers/NotificationController.php
Laravel Shift 0e48e34c8a Adopt PSR-2 coding style
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
2018-01-18 01:04:19 +00:00

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']));
}
}