App\Http\Controllers\DashboardController Class Reference

This controller handles all actions related to the Admin Dashboard for the Snipe-IT Asset Management application. More...

Inheritance diagram for App\Http\Controllers\DashboardController:
App\Http\Controllers\Controller

Public Member Functions

 getIndex ()
 Check authorization and display admin dashboard, otherwise display the user's checked-out assets. More...
 

Detailed Description

This controller handles all actions related to the Admin Dashboard for the Snipe-IT Asset Management application.

Version
v1.0

Definition at line 18 of file DashboardController.php.

Member Function Documentation

App\Http\Controllers\DashboardController::getIndex ( )

Check authorization and display admin dashboard, otherwise display the user's checked-out assets.

Author
[A. Gianotto] [snipe.nosp@m.@sni.nosp@m.pe.ne.nosp@m.t]
Since
[v1.0]
Returns
View

Definition at line 28 of file DashboardController.php.

29  {
30  // Show the page
31  if (Auth::user()->hasAccess('admin')) {
32 
33  $recent_activity = Actionlog::orderBy('created_at', 'DESC')
34  ->with('accessorylog', 'consumablelog', 'licenselog', 'assetlog', 'adminlog', 'userlog')
35  ->take(7)
36  ->get();
37 
38 
39  $asset_stats['total'] = Asset::Hardware()->count();
40 
41  $asset_stats['rtd']['total'] = Asset::Hardware()->RTD()->count();
42 
43  if ($asset_stats['rtd']['total'] > 0) {
44  $asset_stats['rtd']['percent'] = round(($asset_stats['rtd']['total']/$asset_stats['total']) * 100);
45  } else {
46  $asset_stats['rtd']['percent'] = 0;
47  }
48 
49 
50  $asset_stats['pending']['total'] = Asset::Hardware()->Pending()->count();
51 
52  if ($asset_stats['pending']['total'] > 0) {
53  $asset_stats['pending']['percent'] = round(($asset_stats['pending']['total']/$asset_stats['total']) * 100);
54  } else {
55  $asset_stats['pending']['percent'] = 0;
56  }
57 
58 
59  $asset_stats['deployed']['total'] = Asset::Hardware()->Deployed()->count();
60 
61  if ($asset_stats['deployed']['total'] > 0) {
62  $asset_stats['deployed']['percent'] = round(($asset_stats['deployed']['total']/$asset_stats['total']) * 100);
63  } else {
64  $asset_stats['deployed']['percent'] = 0;
65  }
66 
67 
68  $asset_stats['undeployable']['total'] = Asset::Hardware()->Undeployable()->count();
69 
70  if ($asset_stats['undeployable']['total'] > 0) {
71  $asset_stats['undeployable']['percent'] = round(($asset_stats['undeployable']['total']/$asset_stats['total']) * 100);
72  } else {
73  $asset_stats['undeployable']['percent'] = 0;
74  }
75 
76  $asset_stats['archived']['total'] = Asset::Hardware()->Archived()->count();
77 
78  if ($asset_stats['archived']['total'] > 0) {
79  $asset_stats['archived']['percent'] = round(($asset_stats['archived']['total']/$asset_stats['total']) * 100);
80  } else {
81  $asset_stats['archived']['percent'] = 0;
82  }
83 
84 
85  return View::make('dashboard')->with('asset_stats', $asset_stats)->with('recent_activity', $recent_activity);
86  } else {
87  // Redirect to the profile page
88  return Redirect::route('view-assets');
89  }
90  }

The documentation for this class was generated from the following file: