public function index(Advantage $advantage, Crew $crew)
 {
     $this->data['about'] = json_decode(file_get_contents(storage_path() . '/administrator_settings/about.json'));
     $this->data['advantages'] = $advantage->getAdvantages();
     $this->data['crew'] = $crew->getCrew();
     return view('pages.about', $this->data);
 }
Esempio n. 2
0
 public function index()
 {
     $app = app();
     $details = $app->make('stdClass');
     // most recent purchases
     $details->most_recent = Movies::getMovieRecords('purchased', 'DESC', 10);
     // top rated movies
     $details->top_rated = Movies::getTopRated();
     foreach ($details->top_rated as $movie) {
         $movie->rating_display = $this->makeRatingStars($movie->rating);
     }
     // get most popular actors
     $details->actors = Persons::getActorCount(24);
     // get most popular directors
     $details->directors = Persons::getDirectorCount(24);
     $details->birthdays = Persons::getTodaysBirthdays();
     foreach ($details->birthdays as $birthday) {
         $birthday->age = $this->calculateAge($birthday->birthday, $birthday->deceased);
     }
     // highlight randomly selected movie
     $random_id = Movies::selectRandomFilm();
     $details->highlight = Movies::findorfail($random_id);
     $details->highlight->cast = $details->highlight->cast->take(3);
     $details->highlight->crew = Crew::where('movie_id', $random_id)->select(DB::raw('GROUP_CONCAT(CONCAT(persons.forename, " ", persons.surname) SEPARATOR ", ") as list'))->join('persons', 'persons.person_id', '=', 'crew.person_id')->groupBy('movie_id')->where('position', 'Director')->take(1)->get();
     $details->highlight->cover_count = strlen($details->highlight->cover);
     $details->highlight->rating_display = $this->makeRatingStars($details->highlight->rating);
     $details->decades = $this->makeDecades();
     $user = $this->isAdmin;
     return view('welcome', compact('details', 'user'));
 }
Esempio n. 3
0
 public function getMoveInfo($id)
 {
     $truck = Truck::with('moves')->findOrFail($id);
     $moves = $truck->moves;
     foreach ($moves as $move) {
         $crew = Crew::with('movers')->findOrFail($move->crew_id);
         $move->crew = $crew;
     }
     return response()->json($moves);
 }
Esempio n. 4
0
 public function run()
 {
     DB::table('aircrafts')->delete();
     $crew = Crew::where("name", "Grand Canyon Short Haul Crew")->first();
     Shorthaulhelicopter::create(array('tailnumber' => 'N1111', 'model' => 'Astar B350', 'crew_id' => $crew->id));
     Shorthaulhelicopter::create(array('tailnumber' => 'N2222', 'model' => 'MD-900', 'crew_id' => $crew->id));
     $crew = Crew::where("name", "Price Valley")->first();
     Rappelhelicopter::create(array('tailnumber' => 'N3333', 'model' => 'Bell 407', 'crew_id' => $crew->id));
     $crew = Crew::where("name", "Redding Smokejumpers")->first();
     Smokejumperairplane::create(array('tailnumber' => 'J-89', 'model' => 'C-130', 'crew_id' => $crew->id));
     Smokejumperairplane::create(array('tailnumber' => 'J-83', 'model' => 'DHC-6', 'crew_id' => $crew->id));
     //This helicopter is not assigned to a Crew
     Rappelhelicopter::create(array('tailnumber' => 'N4444', 'model' => 'Bell 205', 'crew_id' => null));
 }
Esempio n. 5
0
 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);
 }
 public function run()
 {
     DB::table('crews')->delete();
     DB::table('users')->delete();
     User::create(array('firstname' => 'Evan', 'lastname' => 'Hsu', 'email' => '*****@*****.**', 'encrypted_password' => Hash::make('password'), 'global_admin' => 1));
     User::create(array('firstname' => 'Ed', 'lastname' => 'Ministrator', 'email' => '*****@*****.**', 'encrypted_password' => Hash::make('password'), 'global_admin' => 1));
     $crew = Crew::create(array('name' => 'Grand Canyon Short Haul Crew', 'address_street1' => '3435 North Rim Dr.', 'address_city' => 'Canyon City', 'address_state' => 'AZ', 'address_zip' => '77890', 'phone' => '330-404-5050', 'statusable_type' => "App\\Shorthaulhelicopter"));
     User::create(array('firstname' => 'Grant', 'lastname' => 'Kenyon', 'email' => '*****@*****.**', 'encrypted_password' => Hash::make('password'), 'crew_id' => $crew->id, 'global_admin' => 0));
     $crew = Crew::create(array('name' => 'Price Valley', 'address_street1' => '774 Valley Dr.', 'address_city' => 'Pricetown', 'address_state' => 'ID', 'address_zip' => '54678', 'phone' => '280-324-2909', 'statusable_type' => "App\\Rappelhelicopter"));
     User::create(array('firstname' => 'Pete', 'lastname' => 'Valles', 'email' => '*****@*****.**', 'encrypted_password' => Hash::make('password'), 'crew_id' => $crew->id, 'global_admin' => 0));
     $crew = Crew::create(array('name' => 'Prineville Hotshots', 'address_street1' => '995 Lamonta Rd.', 'address_city' => 'Prineville', 'address_state' => 'OR', 'address_zip' => '97754', 'phone' => '541-887-5477', 'statusable_type' => "App\\Crew"));
     User::create(array('firstname' => 'Prine', 'lastname' => 'Vill', 'email' => '*****@*****.**', 'encrypted_password' => Hash::make('password'), 'crew_id' => $crew->id, 'global_admin' => 0));
     $crew = Crew::create(array('name' => 'Redding Smokejumpers', 'address_street1' => '456 Airport Rd.', 'address_city' => 'Redding', 'address_state' => 'CA', 'address_zip' => '56789', 'phone' => '541-555-6677', 'statusable_type' => "App\\Smokejumperairplane"));
     User::create(array('firstname' => 'Red', 'lastname' => 'Ding', 'email' => '*****@*****.**', 'encrypted_password' => Hash::make('password'), 'crew_id' => $crew->id, 'global_admin' => 0));
 }
Esempio n. 7
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     // Accept a form post from either the Aircraft Status Form (route: 'new_status_for_aircraft')
     // or the Crew Status Form (route: 'new_status_for_crew')
     // Determine whether this is a status update for an Aircraft or a Crew
     // then store the ID of the Crew that owns this object.
     $classname = $request->get('statusable_type');
     $obj = $classname::find($request->get('statusable_id'));
     if (!$obj) {
         // The 'statusable_type' from the form is not one of the polymorphic 'statusable' classes.
         // Add the 'morphMany()' function to the desired class to make it statusable.
         return redirect()->back()->with('alert', array('message' => 'Status update failed! This status update is not linked to a statusable entity', 'type' => 'danger'));
     }
     $crew_id = $obj->get_crew_id();
     $crew = Crew::find($crew_id);
     // Make sure current user is authorized
     if (Auth::user()->cannot('actAsAdminForCrew', $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 update that crew!");
     }
     // This User is authorized - continue...
     $this->validate($request, ['latitude_deg' => 'required', 'latitude_min' => 'required', 'longitude_deg' => 'required', 'longitude_min' => 'required']);
     $latitude_dd = $this->decMinToDecDeg($request->get('latitude_deg'), $request->get('latitude_min'));
     $longitude_dd = $this->decMinToDecDeg($request->get('longitude_deg'), $request->get('longitude_min')) * -1.0;
     // Convert to 'Easting' (Western hemisphere is negative)
     // Form is valid, continue...
     $status = new Status(Input::all());
     // Add a period to the LabelText field - this is a a workaround for the ArcGIS server to be able to render a buffer around the shorthaulhelicopter features
     $status->LabelText = ".";
     // Insert the identity of the User who created this Status update (the CURRENT user):
     $status->created_by_name = Auth::user()->fullname();
     $status->created_by_id = Auth::user()->id;
     // Insert the name of the Crew that owns this Status update (if this Status refers to a Crew, then 'crew_name' will be the same as 'statusable_name')
     $status->crew_name = Crew::find($crew_id)->name;
     // Insert the lat and lon in decimal-degree format
     $status->latitude = $latitude_dd;
     $status->longitude = $longitude_dd;
     // Change the 'statusable_type' variable to a fully-namespaced class name (the html form only submits the class name, but not the namespace)
     // i.e. Change 'Shorthaulhelicopter' to 'App\Shorthaulhelicopter'. This is required for the Status class to be able to retrieve the correct Aircraft (or Crew).
     //$status->statusable_type = "App\\".ucwords($status->statusable_type);
     $status->created_at = date('Y-m-d H:m:s');
     // Temporarily set the timestamp so that it can be included in the popup (timestamp will be reset when $status is saved)
     // Build the HTML popup that will be displayed when this feature is clicked
     $status->popupinfo = $this->generatePopup($status, $crew);
     // Attempt to save
     if ($status->save()) {
         // Changes have been saved to the local database, now initiate an update on the ArcGIS Server...
         // Render a different popup view to be sent to the EGP, but don't save it locally
         $status->popupinfo = $this->generatePopup($status, $crew, "egp");
         $objectids = ArcServer::findFeature($status);
         if ($objectids === false) {
             // An error occurred in findFeature() - check 'laravel.log' for details
             return redirect()->back()->with('alert', array('message' => 'Status update was saved locally, but could not be sent to the EGP (findFeature error).', 'type' => 'danger'));
         } elseif (!isset($objectids[0]) || $objectids[0] == '') {
             // The server responded, but the request feature was not found - add it.
             $result = ArcServer::addFeature($status);
         } else {
             // The Feature being updated was found on the ArcGIS server - now update it.
             $objectid = $objectids[0];
             $result = ArcServer::updateFeature($objectid, $status);
         }
         // Check the ArcGIS server response to determine if the operation was successful or not.
         if (empty($result->error)) {
             return redirect()->back()->with('alert', array('message' => 'Status update saved!', 'type' => 'success'));
         } else {
             return redirect()->back()->with('alert', array('message' => 'Status update was saved locally, but could not be sent to the EGP: ' . $result->error, 'type' => 'danger'));
         }
     }
     return redirect()->back()->with('alert', array('message' => 'Status update failed!', 'type' => 'danger'));
 }
Esempio n. 8
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     if (!Auth::user()->isGlobalAdmin()) {
         // Only Global Admins can access this
         return redirect()->back()->withErrors("Unauthorized");
     }
     $crew = Crew::find($id);
     $crew_name = $crew->name;
     // Release all Aircrafts from this crew (null the crew_id field in the aircrafts table)
     if ($crew->is_an_aircraft_crew()) {
         $aircrafts = $crew->aircrafts;
         foreach ($aircrafts as $aircraft) {
             $aircraft->release();
         }
     }
     // Delete all Users belonging to this crew
     foreach ($crew->users as $user) {
         $user->delete();
     }
     $crew->delete();
     return redirect()->route('crews_index')->with('alert', array('message' => "'" . $crew_name . "' was deleted.", 'type' => 'success'));
 }
Esempio n. 9
0
 /**
  *
  * Remove crew member from movie
  * @return Response
  *
  */
 public function removeCrewMember()
 {
     if ($this->isAdmin) {
         if (Request::ajax()) {
             $data = Request::all();
             $movie_id = $data['movie'];
             $crew_id = $data['row'];
             $movie = Movies::findorfail($movie_id);
             Crew::find($crew_id)->delete();
             return (string) view('movies.crew', compact('movie'));
         }
     }
     return "error";
 }
Esempio n. 10
0
 public function index(Request $request)
 {
     if (!Auth::user()->isGlobalAdmin()) {
         // Only Global Admins can access this
         return redirect()->back()->withErrors("Unauthorized");
     }
     // Authorization complete - continue...
     $users = User::orderBy('firstname', 'asc')->orderBy('lastname', 'asc')->get();
     $crews = Crew::orderBy('name')->get();
     $request->session()->flash('active_menubutton', 'accounts');
     // Tell the menubar which button to highlight
     return view('auth.index', ['users' => $users, 'crews' => $crews]);
 }