Example #1
0
 /**
  * Display a listing of the resource.
  * 
  *
  * @return \Illuminate\Http\Response
  */
 public function getIncident($type_incident, $id_qr)
 {
     //
     if ($type_incident == 'poubelle') {
         $incident = new Incident();
         $incident->id_type = 0;
         $incident->id_user = 0;
         $incident->date = date("Y-m-d H:i:s");
         if (array_key_exists($id_qr, $this->loc_qr_code_poubelle)) {
             $incident->lat = $this->loc_qr_code_poubelle[$id_qr]['lat'];
             $incident->lng = $this->loc_qr_code_poubelle[$id_qr]['lng'];
         } else {
             $incident->lat = 0;
             $incident->lng = 0;
         }
         $incident->commentaire = $id_qr . " " . $type_incident;
         $incident->save();
     } elseif ($type_incident == 'eclairage') {
         $incident = new Incident();
         $incident->id_type = 0;
         $incident->id_user = 0;
         $incident->date = date("Y-m-d H:i:s");
         if (array_key_exists($id_qr, $this->loc_qr_code_eclairage)) {
             $incident->lat = $this->loc_qr_code_eclairage[$id_qr]['lat'];
             $incident->lng = $this->loc_qr_code_eclairage[$id_qr]['lng'];
         } else {
             $incident->lat = 0;
             $incident->lng = 0;
         }
         $incident->commentaire = $id_qr . " " . $type_incident;
         $incident->save();
     } elseif ($type_incident == 'degradation') {
         $incident = new Incident();
         $incident->id_type = 0;
         $incident->id_user = 0;
         $incident->date = date("Y-m-d H:i:s");
         if (array_key_exists($id_qr, $this->loc_qr_code_degradation)) {
             $incident->lat = $this->loc_qr_code_degradation[$id_qr]['lat'];
             $incident->lng = $this->loc_qr_code_degradation[$id_qr]['lng'];
         } else {
             $incident->lat = 0;
             $incident->lng = 0;
         }
         $incident->commentaire = $id_qr . " " . $type_incident;
         $incident->save();
     }
     return view('merci');
 }
Example #2
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);
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     //
     $incident = Incident::find($id);
     $incident->lat = str_replace(',', '.', $incident->lat);
     $incident->lng = str_replace(',', '.', $incident->lng);
     return view('detail')->with('scan', $incident);
 }
Example #4
0
 public function closeIncident($incidentId, Request $request)
 {
     $incident = Incident::find($incidentId);
     $incident->update(['status' => 'closed', 'closed_at' => date('Y-m-d h:i:s')]);
     Comment::create(['incident_id' => $incident->id, 'comment' => 'Cierre de incidente: ' . $request->input('comment'), 'user_id' => Auth::user()->id]);
     $request->session()->flash('alert-success', 'El incidente número <strong>' . $incident->id . '</strong> ha sido cerrado con éxito');
     return redirect('/dashboard');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $incident = new Incident();
     // incident Model 内容
     $incident->name_jp = Input::get('name_jp');
     $incident->name_en = Input::get('name_en');
     $incident->name_cn = Input::get('name_cn');
     $incident->desc_jp = Input::get('desc_jp');
     $incident->desc_en = Input::get('desc_en');
     $incident->desc_cn = Input::get('desc_cn');
     $incident->type = Input::get('type');
     $incident->target_category = Input::get('target_category');
     $incident->target_race = Input::get('target_race');
     $incident->target_rare = Input::get('target_rare');
     $incident->target_attr = Input::get('target_attr');
     $incident->target_job = Input::get('target_job');
     if ($incident->save()) {
         return Redirect::to('admin/incident');
     } else {
         return Redirect::back()->withInput()->withErrors('保存失败!');
     }
 }
Example #6
0
    Incident description
    Type of Incident
    Incident date
    Incident city
    Victim's gender
    Victim's country of origin
    LINK TO ARTICLE OR SOURCE OF INFORMATION
    Your contact information (Optional)
    Incident country
    Who is reporting?
 */
 $reader = Reader::createFromString($csv, "\n");
 $data = $reader->fetchAssoc();
 $incidents = [];
 foreach ($data as $index => $row) {
     $incident = new Incident();
     $incident->description = $row['Incident description'];
     $incident->date = $row['Incident date'];
     $incident->created_at = $row['Timestamp'];
     $incident->city = $row['Incident city'];
     $incident->country = $row['Incident country'];
     $incident->type = $row['Type of Incident'];
     $incident->link = $row['LINK TO ARTICLE OR SOURCE OF INFORMATION'];
     $incident->victimCountry = $row['Victim\'s country of origin'];
     $incident->victimGender = $row['Victim\'s gender'];
     $incident->reporterType = $row['Who is reporting?'];
     $incident->reporterContact = $row['Your contact information (Optional)'];
     //get geocode
     $geocode = new Geocode($incident->address());
     $incident->lat = $geocode->getLatitude();
     $incident->long = $geocode->getLongitude();
Example #7
0
 /**
  * 冒险中的事件发生处理 完成度20%
  * @param $objBattle
  * @return mixed
  */
 public function happen($objBattle)
 {
     // 取得事件的Master内容
     $objIncident = Incident::find($this->incident_id);
     if (empty($objIncident->target_category) || !$objIncident->target_category) {
         return $objBattle;
     }
     // 根据事件类型进行不同处理
     switch ($objIncident->target_category) {
         case 'hp':
             if ($objIncident->type == 'good') {
                 $objBattle->buff_hp = $objBattle->buff_hp + $this->power;
             } else {
                 $objBattle->buff_hp = $objBattle->buff_hp - $this->power;
             }
             break;
         case 'atk':
             if ($this->type == 'good') {
                 $objBattle->buff_atk = $objBattle->buff_atk + $this->power;
             } else {
                 $objBattle->buff_atk = $objBattle->buff_atk - $this->power;
             }
             break;
         case 'def':
             if ($objIncident->type == 'good') {
                 $objBattle->buff_def = $objBattle->buff_def + $this->power;
             } else {
                 $objBattle->buff_def = $objBattle->buff_def - $this->power;
             }
             break;
         case 'spd':
             if ($objIncident->type == 'good') {
                 $objBattle->buff_spd = $objBattle->buff_spd + $this->power;
             } else {
                 $objBattle->buff_spd = $objBattle->buff_spd - $this->power;
             }
             break;
         case 'spd':
             if ($objIncident->type == 'good') {
                 $objBattle->buff_spd = $objBattle->buff_spd + $this->power;
             } else {
                 $objBattle->buff_spd = $objBattle->buff_spd - $this->power;
             }
             break;
         case 'card':
             break;
         case 'item':
             break;
         case 'money':
             $player = Player::find($objBattle->player_id);
             if ($objIncident->type == 'good') {
                 $player->appendMoney($this->power);
             } else {
                 $player->appendMoney(0 - $this->power);
             }
             break;
         default:
             # code...
             break;
     }
     return $objBattle;
 }
Example #8
0
 /**
  * 新建地下城事件
  * @param $intDungeonId
  * @return mixed
  */
 public function incidentCreate($intDungeonId)
 {
     return view('admin.dungeon.incident-create')->withDungeon(Dungeon::find($intDungeonId))->withIncidents(Incident::all());
 }