Exemplo n.º 1
0
 public function filterLogs($id, $transaction)
 {
     if (Session::has('username') && (Session::get('user_type') == "Root" || Session::get('user_type') == "Admin" || Session::get("user_type") == "User")) {
         if (Session::get("user_type") == "User") {
             return Redirect::to("assets/network/logs/" . $id);
         }
         $view = View::make("Assets.Network.network_logs");
         $view->nav = "assets";
         $asset = Asset::where("id", "=", $id)->whereHas("classification", function ($query) {
             $query->where("type", "=", "Network");
         })->first();
         if (!$asset) {
             return Redirect::to("assets");
         }
         if (!in_array($transaction, array("history", "updates"))) {
             return Redirect::to("assets");
         }
         $view->asset = $asset;
         $view->transaction = $transaction;
         $view->logs = AssetLog::where("asset_id", "=", $id)->where("transaction", "=", $transaction)->orderBy("datetime", "desc")->paginate(25);
         $view->logCount = AssetLog::where("asset_id", "=", $id)->where("transaction", "=", $transaction)->orderBy("datetime", "desc")->count();
         return $view;
     } else {
         return Redirect::to("/");
     }
 }