Esempio n. 1
0
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
App::singleton('oauth2', function () {
    $storage = new OAuth2\Storage\Mongo(App::make('db')->getMongoDB());
    $server = new OAuth2\Server($storage);
    $server->addGrantType(new OAuth2\GrantType\ClientCredentials($storage));
    return $server;
});
Route::get('/', function () {
    if (Auth::check()) {
        $site = \Site::first();
        $admin_dashboard = new \app\locker\data\dashboards\AdminDashboard();
        //if super admin, show site dashboard, otherwise show list of LRSs can access
        if (Auth::user()->role == 'super') {
            $list = Lrs::all();
            return View::make('partials.site.dashboard', array('site' => $site, 'list' => $list, 'stats' => $admin_dashboard->getFullStats(), 'graph_data' => $admin_dashboard->getGraphData(), 'dash_nav' => true));
        } else {
            $lrs = Lrs::where('users._id', \Auth::user()->_id)->get();
            return View::make('partials.lrs.list', array('lrs' => $lrs, 'list' => $lrs, 'site' => $site));
        }
    } else {
        $site = \Site::first();
        if (isset($site)) {
            return View::make('system.forms.login', array('site' => $site));
        } else {
            return View::make('system.forms.register');
        }
 /**
  * Grab site stats
  * @return Response
  **/
 public function getGraphData()
 {
     $startDate = \LockerRequest::getParam('graphStartDate');
     $endDate = \LockerRequest::getParam('graphEndDate');
     $startDate = !$startDate ? null : new \Carbon\Carbon($startDate);
     $endDate = !$endDate ? null : new \Carbon\Carbon($endDate);
     $admin_dashboard = new \app\locker\data\dashboards\AdminDashboard();
     $graph_data = $admin_dashboard->getGraphData($startDate, $endDate);
     return Response::json($graph_data);
 }