/** * @param $configdepart * @return bool */ private function saveFlights(Configdepart $configdepart) { // Combien de flights à créer $nbFlights = ceil($configdepart->nbjoueurs / $configdepart->slotbyflight) + $configdepart->startergap; // Met a jour Configdepart->slotcount : nombre de places disponibes créees $configdepart->slotcount = $nbFlights * $configdepart->slotbyflight; $configdepart->save(); // Supprimer les Flight de cette config $configdepart->flights()->delete(); // Boucle tous les flight à créer for ($i = 1; $i <= $nbFlights; $i++) { $addMinutes = ($i - 1) * $configdepart->interval; $newheure = Carbon::createFromFormat('H:i', $configdepart->startheure)->addMinutes($addMinutes); // New Flight $flight = new Flight(); $flight->configdepart_id = $configdepart->id; $flight->num = $i; $flight->heure = $newheure; $flight->save(); // Cree les slots for ($slotnum = 1; $slotnum <= $configdepart->slotbyflight; $slotnum++) { $slot = new Slot(); $slot->flight_id = $flight->id; $slot->num = $slotnum; $slot->entree_id = 0; $slot->save(); } } return true; }
function show(Flight $flight) { if ($flight->missing) { Messages::error('This flight has been missing for ' . Carbon::now()->diffInMinutes($flight->updated_at) . ' minutes. It will be deleted if it has been missing for 1 hour.')->one(); } if ($flight->pilot->getOriginal('updated_at') == '0000-00-00 00:00:00') { Queue::push('LegacyUpdate', $flight->pilot->vatsim_id, 'legacy'); $flight->pilot->processing = 2; $flight->pilot->save(); } $flightplan = new FlightPlan($flight->route, $flight->departure->lat, $flight->departure->lon, $flight->departure_id, $flight->arrival_id); if (empty($flight->route_parsed)) { $flight->route_parsed = $flightplan->toString(); $flight->save(); } $flight->miles = $flight->distance * 0.54; $this->javascript('assets/javascript/jquery.flot.min.js'); $this->javascript('assets/javascript/jquery.flot.time.min.js'); $this->stylesheet('assets/stylesheets/flightplan.css'); $this->autoRender(compact('flight', 'flightplan'), $flight->callsign); }