NotifierController::index()   B
last analyzed

Complexity

Conditions 7
Paths 4

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
c 0
b 0
f 0
rs 8.2222
cc 7
eloc 7
nc 4
nop 0
1
<?php namespace Cornford\Notifier\Controllers;
2
3
use App\Http\Controllers\Controller as BaseController;
4
use Illuminate\Support\Facades\Request;
5
use Illuminate\Support\Facades\Response;
6
use Cornford\Notifier\Facades\NotifierFacade as Notifier;
7
use Illuminate\Support\Facades\Route;
8
9
class NotifierController extends BaseController {
10
11
	/**
12
	 * Display a listing of the resource.
13
	 *
14
	 * @return Response
15
	 */
16
	public function index()
17
	{
18
		if ((Request::ajax() && Route::is('notifier.index')) || !Request::ajax()) {
19
			Notifier::expireDisplayedNotifications();
20
		}
21
22
		$notifications = Notifier::getDisplayNotifications();
23
24
		if ((Request::ajax() && Route::is('notifier.index')) || !Request::ajax()) {
25
			Notifier::displayNotifications($notifications);
26
		}
27
28
		return Response::json(['notifications' => Notifier::toArray($notifications)]);
29
	}
30
31
}