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')); }
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)); }
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); }