2016-03-25 01:18:05 -07:00
|
|
|
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use App\Http\Controllers\AdminController;
|
|
|
|
use App\Models\Actionlog;
|
|
|
|
use View;
|
|
|
|
use Auth;
|
|
|
|
use Redirect;
|
|
|
|
use App\Models\Asset;
|
|
|
|
use App\Models\Company;
|
|
|
|
|
2016-04-07 13:21:09 -07:00
|
|
|
/**
|
|
|
|
* This controller handles all actions related to the Admin Dashboard
|
|
|
|
* for the Snipe-IT Asset Management application.
|
|
|
|
*
|
|
|
|
* @version v1.0
|
|
|
|
*/
|
2016-03-25 01:18:05 -07:00
|
|
|
class DashboardController extends Controller
|
|
|
|
{
|
|
|
|
/**
|
2016-04-07 13:21:09 -07:00
|
|
|
* Check authorization and display admin dashboard, otherwise display
|
|
|
|
* the user's checked-out assets.
|
|
|
|
*
|
|
|
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
|
|
|
* @since [v1.0]
|
|
|
|
* @return View
|
|
|
|
*/
|
2016-03-25 01:18:05 -07:00
|
|
|
public function getIndex()
|
|
|
|
{
|
|
|
|
// Show the page
|
|
|
|
if (Auth::user()->hasAccess('admin')) {
|
|
|
|
|
2017-05-09 00:38:45 -07:00
|
|
|
$asset_stats=null;
|
2016-03-25 01:18:05 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
2017-05-09 00:38:45 -07:00
|
|
|
if ((!file_exists(storage_path().'/oauth-private.key')) || (!file_exists(storage_path().'/oauth-public.key'))) {
|
|
|
|
\Artisan::call('passport:install');
|
|
|
|
\Artisan::call('migrate', ['--force' => true]);
|
2016-03-25 01:18:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-09-29 22:20:49 -07:00
|
|
|
return View::make('dashboard')->with('asset_stats', $asset_stats);
|
2016-03-25 01:18:05 -07:00
|
|
|
} else {
|
|
|
|
// Redirect to the profile page
|
2016-10-29 07:32:48 -07:00
|
|
|
return redirect()->intended('account/view-assets');
|
2016-03-25 01:18:05 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|