Beispiel #1
0
 public function index()
 {
     $logged_user = Auth::user();
     $logged_user->company;
     if (Auth::user()->isAdmin()) {
         $incidents = Incident::all();
     } else {
         $incidentsQuery = Incident::with(['creator' => function ($query) {
             $query->where('company_id', Auth::user()->company_id);
         }]);
         $incidents = $incidentsQuery->get();
     }
     // Add status labels
     foreach ($incidents as &$incident) {
         $incident->status_label = $incident->getStatusLabel();
     }
     // Get number of open incidents
     $num_open = $incidents->filter(function ($incident) {
         return $incident->status == 'open';
     })->count();
     // Get number of incidents in process
     $num_process = $incidents->filter(function ($incident) {
         return $incident->status == 'process';
     })->count();
     // Get number of closed incidents
     $num_closed = $incidents->filter(function ($incident) {
         return $incident->status == 'closed';
     })->count();
     $viewData = ['logged_user' => $logged_user, 'incidents' => $incidents, 'num_open' => $num_open, 'num_process' => $num_process, 'num_closed' => $num_closed];
     if (Auth::user()->isAdmin()) {
         return view('pages.dashboard.admin-dashboard', $viewData);
     } else {
         return view('pages.dashboard.user-dashboard', $viewData);
     }
 }
 /**
  * 新建地下城事件
  * @param $intDungeonId
  * @return mixed
  */
 public function incidentCreate($intDungeonId)
 {
     return view('admin.dungeon.incident-create')->withDungeon(Dungeon::find($intDungeonId))->withIncidents(Incident::all());
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     //
     return view('admin.incident.incident')->withIncidents(Incident::all());
 }