public function run() { DB::table('statuses')->delete(); $rightNow = Carbon::now(); $heli = Aircraft::where("tailnumber", "N1111")->first(); $user = User::where("crew_id", $heli->crew_id)->first(); $crew = $heli->crew; $oldtime = Carbon::now()->subday(); // A timestamp from yesterday $statusArray = array('statusable_type' => $crew->statusable_type, 'statusable_id' => $heli->id, 'statusable_name' => $heli->tailnumber, 'latitude' => 42.454223, 'longitude' => -123.310388, 'staffing_value1' => "3", 'staffing_value2' => "4", 'manager_name' => "Bob Nielson", 'manager_phone' => "789-566-4430", 'comments1' => "This is update 1 of 2 from the db seeder", 'comments2' => "This is upcoming", 'assigned_fire_name' => "Gasquet Complex", 'assigned_fire_number' => "WA-FRE-150038", 'assigned_supervisor' => "John Thompson", 'assigned_supervisor_phone' => "333-444-5555", 'Distance' => 100, 'LabelText' => ".", 'created_by_name' => $user->firstname . " " . $user->lastname, 'created_by_id' => $user->id, 'created_at' => $oldtime, 'updated_at' => $oldtime, 'crew_name' => $crew->name, 'popupinfo' => ""); $statusArray['popupinfo'] = $this->createPopupinfo($statusArray); $status = Status::create($statusArray); $statusArray = array('statusable_type' => $crew->statusable_type, 'statusable_id' => $heli->id, 'statusable_name' => $heli->tailnumber, 'latitude' => 42.464223, 'longitude' => -121.210388, 'staffing_value1' => "3", 'staffing_value2' => "4", 'manager_name' => "Bob Nielson", 'manager_phone' => "789-566-4430", 'comments1' => "This is update 2 of 2 from the db seeder", 'comments2' => "This is upcoming", 'assigned_fire_name' => "Gasquet Complex", 'assigned_fire_number' => "WA-FRE-150038", 'assigned_supervisor' => "John Thompson", 'assigned_supervisor_phone' => "333-444-5555", 'Distance' => 100, 'LabelText' => ".", 'created_by_name' => $user->firstname . " " . $user->lastname, 'created_by_id' => $user->id, 'created_at' => $rightNow, 'updated_at' => $rightNow, 'crew_name' => $crew->name, 'popupinfo' => ""); $statusArray['popupinfo'] = $this->createPopupinfo($statusArray); $status = Status::create($statusArray); $heli = Aircraft::where("tailnumber", "N2222")->first(); $user = User::where("crew_id", $heli->crew_id)->first(); $crew = $heli->crew; $statusArray = array('statusable_type' => $crew->statusable_type, 'statusable_id' => $heli->id, 'statusable_name' => $heli->tailnumber, 'latitude' => 44.084223, 'longitude' => -119.310388, 'staffing_value1' => "3", 'staffing_value2' => "4", 'manager_name' => "Jim Lewis", 'manager_phone' => "250-778-5443", 'comments1' => "This is update 1 of 1 from the db seeder", 'comments2' => "This is upcoming", 'assigned_fire_name' => "Big Windy", 'assigned_fire_number' => "OR-RSF-150208", 'assigned_supervisor' => "Bill Newman", 'assigned_supervisor_phone' => "333-444-5555", 'Distance' => 100, 'LabelText' => ".", 'created_by_name' => $user->firstname . " " . $user->lastname, 'created_by_id' => $user->id, 'created_at' => $rightNow, 'updated_at' => $rightNow, 'crew_name' => $crew->name, 'popupinfo' => ""); $statusArray['popupinfo'] = $this->createPopupinfo($statusArray); $status = Status::create($statusArray); $heli = Aircraft::where("tailnumber", "N3333")->first(); $user = User::where("crew_id", $heli->crew_id)->first(); $crew = $heli->crew; $statusArray = array('statusable_type' => $crew->statusable_type, 'statusable_id' => $heli->id, 'statusable_name' => $heli->tailnumber, 'latitude' => 46.384223, 'longitude' => -115.310388, 'staffing_value1' => "3", 'staffing_value2' => "4", 'manager_name' => "Steve Borland", 'manager_phone' => "334-998-6756", 'comments1' => "This is update 1 of 1 from the db seeder", 'comments2' => "This is upcoming", 'assigned_fire_name' => "", 'assigned_fire_number' => "", 'assigned_supervisor' => "", 'assigned_supervisor_phone' => "", 'Distance' => 100, 'LabelText' => ".", 'created_by_name' => $user->firstname . " " . $user->lastname, 'created_by_id' => $user->id, 'created_at' => $rightNow, 'updated_at' => $rightNow, 'crew_name' => $crew->name, 'popupinfo' => ""); $statusArray['popupinfo'] = $this->createPopupinfo($statusArray); $status = Status::create($statusArray); $heli = Aircraft::where("tailnumber", "J-83")->first(); $user = User::where("crew_id", $heli->crew_id)->first(); $crew = $heli->crew; $statusArray = array('statusable_type' => $crew->statusable_type, 'statusable_id' => $heli->id, 'statusable_name' => $heli->tailnumber, 'latitude' => 38.51106, 'longitude' => -118.441425, 'staffing_value1' => "3", 'staffing_value2' => "4", 'manager_name' => "Mark Kennedy", 'manager_phone' => "789-432-2120", 'comments1' => "This is update 1 of 1 from the db seeder", 'comments2' => "This is upcoming", 'assigned_fire_name' => "", 'assigned_fire_number' => "", 'assigned_supervisor' => "", 'assigned_supervisor_phone' => "", 'Distance' => 100, 'LabelText' => ".", 'created_by_name' => $user->firstname . " " . $user->lastname, 'created_by_id' => $user->id, 'created_at' => $rightNow, 'updated_at' => $rightNow, 'crew_name' => $crew->name, 'popupinfo' => ''); $statusArray['popupinfo'] = $this->createPopupinfo($statusArray); $status = Status::create($statusArray); $heli = Aircraft::where("tailnumber", "J-89")->first(); $user = User::where("crew_id", $heli->crew_id)->first(); $crew = $heli->crew; $oldtime = Carbon::now()->subDays(3); // A stale timestamp $statusArray = array('statusable_type' => $crew->statusable_type, 'statusable_id' => $heli->id, 'statusable_name' => $heli->tailnumber, 'latitude' => 45.281331, 'longitude' => -116.225388, 'staffing_value1' => "3", 'staffing_value2' => "4", 'manager_name' => "Pat Stone", 'manager_phone' => "530-448-8581", 'comments1' => "This is update 1 of 1 from the db seeder", 'comments2' => "This is upcoming", 'assigned_fire_name' => "Morning Fire", 'assigned_fire_number' => "MT-FFT-150038", 'assigned_supervisor' => "Gary Pickett", 'assigned_supervisor_phone' => "333-444-5555", 'Distance' => 100, 'LabelText' => ".", 'created_by_name' => $user->firstname . " " . $user->lastname, 'created_by_id' => $user->id, 'created_at' => $oldtime, 'updated_at' => $oldtime, 'crew_name' => $crew->name, 'popupinfo' => ''); $statusArray['popupinfo'] = $this->createPopupinfo($statusArray); $status = Status::create($statusArray); $crew = Crew::where("name", "Prineville Hotshots")->first(); $user = User::where("crew_id", $crew->id)->first(); $oldtime = Carbon::now()->subDays(3); // A stale timestamp $statusArray = array('statusable_type' => $crew->statusable_type, 'statusable_id' => $crew->id, 'statusable_name' => $crew->name, 'latitude' => 45.281331, 'longitude' => -111.225388, 'staffing_value1' => "3", 'staffing_value2' => "4", 'manager_name' => "Pat Stone", 'manager_phone' => "530-448-8581", 'comments1' => "This is update 1 of 1 from the db seeder", 'comments2' => "This is upcoming", 'assigned_fire_name' => "Morning Fire", 'assigned_fire_number' => "MT-FFT-150038", 'assigned_supervisor' => "Gary Pickett", 'assigned_supervisor_phone' => "333-444-5555", 'Distance' => 100, 'LabelText' => ".", 'created_by_name' => $user->firstname . " " . $user->lastname, 'created_by_id' => $user->id, 'created_at' => $oldtime, 'updated_at' => $oldtime, 'crew_name' => $crew->name, 'popupinfo' => ''); $statusArray['popupinfo'] = $this->createPopupinfo($statusArray); $status = Status::create($statusArray); }
/** * Display the Aircraft Status update form * Note: this form POSTS its response to the StatusController */ public function newStatus(Request $request, $tailnumber) { // Determine the subclass for this Aircraft (Shorthaulhelicopter, Rappelhelicopter, Smokejumperairplane, etc) $aircraft = Aircraft::where('tailnumber', '=', $tailnumber)->first(); if (is_null($aircraft)) { return "Aircraft not found"; } $aircraft = $aircraft->subclass(); // Instantiate a child class (Rappelhelicopter, for example) NOT the parent "Aircraft" class // Make sure this user is authorized... if (Auth::user()->cannot('actAsAdminForCrew', $aircraft->crew_id)) { // The current user does not have permission to perform admin functions for this crew return redirect()->back()->withErrors("You're not authorized to access that aircraft!"); } // Authorization complete - continue... // Retrieve the other Aircrafts that are owned by the same Crew (to build a navigation menu) $crew = $aircraft->crew; $aircraft_class = $aircraft->classname(); $crew_aircrafts = $aircraft_class::where('crew_id', $aircraft->crew_id)->orderBy('tailnumber')->get(); // Retrieve the most recent status update to prepopulate the form (returns a 'new Status' if none exist) $last_status = $aircraft->status(); // Convert the lat and lon from decimal-degrees into decimal-minutes // MOVE THIS FUNCTIONALITY INTO A COORDINATES CLASS if (!empty($last_status->latitude)) { $sign = $last_status->latitude >= 0 ? 1 : -1; // Keep track of whether the latitude is positive or negative $last_status->latitude_deg = floor(abs($last_status->latitude)) * $sign; $last_status->latitude_min = round((abs($last_status->latitude) - $last_status->latitude_deg) * 60.0, 4); } else { $last_status->latitude_deg = ""; $last_status->latitude_min = ""; } if (!empty($last_status->longitude)) { $sign = $last_status->longitude >= 0 ? 1 : -1; // Keep track of whether the longitude is positive or negative $last_status->longitude_deg = floor(abs($last_status->longitude)) * $sign * -1; // Convert to 'West-positive' reference $last_status->longitude_min = round((abs($last_status->longitude) - $last_status->longitude_deg) * 60.0, 4); } else { $last_status->longitude_deg = ""; $last_status->longitude_min = ""; } // Display the status update form if (Auth::user()->isGlobalAdmin()) { $request->session()->flash('active_menubutton', 'aircraft'); // Tell the menubar which button to highlight } else { $request->session()->flash('active_menubutton', 'status'); // Tell the menubar which button to highlight } // return view('aircrafts.new_status')->with("aircraft",$aircraft)->with("aircrafts",$crew_aircrafts)->with("status",$last_status)->with("crew",$crew); $resource_type = $crew->statusable_type_plain(); return view('status_forms.' . $resource_type)->with("aircraft", $aircraft)->with("aircrafts", $crew_aircrafts)->with("status", $last_status)->with("crew", $crew); // return view('status_forms.shorthaulhelicopter')->with("aircraft",$aircraft)->with("aircrafts",$crew_aircrafts)->with("status",$last_status)->with("crew",$crew); // return var_dump($aircraft); // return var_dump($last_status); }