public function get($id)
 {
     $companion = Companion::with(['doctors', 'episodes'])->find($id);
     $ratings = Rating::getRating('companion', $id);
     $comments = Comment::where('item_id', $id)->where('item_type', 'companion')->with('user')->orderBy('created_at', 'desc')->get();
     return View::make('items.companion', ['companion' => $companion, 'ratings' => $ratings, 'comments' => $comments]);
 }
 public function index()
 {
     $doctors = Doctor::take(4)->orderBy('number')->get();
     $companions = Companion::take(4)->get();
     $enemies = Enemy::take(4)->get();
     $episodes = Episode::take(4)->get();
     return View::make('index', ['doctors' => $doctors, 'companions' => $companions, 'enemies' => $enemies, 'episodes' => $episodes]);
 }
 public function run()
 {
     DB::table('ratings')->delete();
     // Going to randomize all our ratings for our users, so throw everything in
     // an array.
     $toRate = array(array('item' => Doctor::where('number', 9)->first(), 'type' => 'doctor'), array('item' => Doctor::where('number', 10)->first(), 'type' => 'doctor'), array('item' => Doctor::where('number', 11)->first(), 'type' => 'doctor'), array('item' => Doctor::where('number', 12)->first(), 'type' => 'doctor'), array('item' => Enemy::where('name', 'Cybermen')->first(), 'type' => 'enemy'), array('item' => Enemy::where('name', 'Daleks')->first(), 'type' => 'enemy'), array('item' => Enemy::where('name', 'Sontarans')->first(), 'type' => 'enemy'), array('item' => Enemy::where('name', 'The Silence')->first(), 'type' => 'enemy'), array('item' => Enemy::where('name', 'Weeping Angels')->first(), 'type' => 'enemy'), array('item' => Companion::where('name', 'Amy Pond')->first(), 'type' => 'companion'), array('item' => Companion::where('name', 'Captain Jack')->first(), 'type' => 'companion'), array('item' => Companion::where('name', 'Clara Oswald')->first(), 'type' => 'companion'), array('item' => Companion::where('name', 'Donna Noble')->first(), 'type' => 'companion'), array('item' => Companion::where('name', 'Martha Jones')->first(), 'type' => 'companion'), array('item' => Companion::where('name', 'Mickey Smith')->first(), 'type' => 'companion'), array('item' => Companion::where('name', 'River Song')->first(), 'type' => 'companion'), array('item' => Companion::where('name', 'Rory Williams')->first(), 'type' => 'companion'), array('item' => Companion::where('name', 'Rose Tyler')->first(), 'type' => 'companion'), array('item' => Companion::where('name', 'Wilfred Mott')->first(), 'type' => 'companion'), array('item' => Episode::where('season', 1)->where('episode', 1)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 1)->where('episode', 6)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 1)->where('episode', 10)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 1)->where('episode', 12)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 2)->where('episode', 5)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 2)->where('episode', 12)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 3)->where('episode', 9)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 3)->where('episode', 10)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 4)->where('episode', 4)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 4)->where('episode', 13)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 5)->where('episode', 3)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 5)->where('episode', 4)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 5)->where('episode', 12)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 6)->where('episode', 1)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 6)->where('episode', 10)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 6)->where('episode', 13)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 7)->where('episode', 5)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 7)->where('episode', 12)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 8)->where('episode', 2)->first(), 'type' => 'episode'));
     $users = User::get();
     // Loop through our users
     foreach ($users as $user) {
         // Loop through things to be rated
         foreach ($toRate as $item) {
             $rating = rand(1, 5);
             Rating::create(array('user_id' => $user->id, 'item_id' => $item['item']->id, 'item_type' => $item['type'], 'rating' => $rating));
         }
     }
 }
 public function run()
 {
     DB::table('comments')->delete();
     // Going to randomize all our ratings for our users, so throw everything in
     // an array.
     $toComment = array(array('item' => Doctor::where('number', 9)->first(), 'type' => 'doctor'), array('item' => Doctor::where('number', 10)->first(), 'type' => 'doctor'), array('item' => Doctor::where('number', 11)->first(), 'type' => 'doctor'), array('item' => Doctor::where('number', 12)->first(), 'type' => 'doctor'), array('item' => Enemy::where('name', 'Cybermen')->first(), 'type' => 'enemy'), array('item' => Enemy::where('name', 'Daleks')->first(), 'type' => 'enemy'), array('item' => Enemy::where('name', 'Sontarans')->first(), 'type' => 'enemy'), array('item' => Enemy::where('name', 'The Silence')->first(), 'type' => 'enemy'), array('item' => Enemy::where('name', 'Weeping Angels')->first(), 'type' => 'enemy'), array('item' => Companion::where('name', 'Amy Pond')->first(), 'type' => 'companion'), array('item' => Companion::where('name', 'Captain Jack')->first(), 'type' => 'companion'), array('item' => Companion::where('name', 'Clara Oswald')->first(), 'type' => 'companion'), array('item' => Companion::where('name', 'Donna Noble')->first(), 'type' => 'companion'), array('item' => Companion::where('name', 'Martha Jones')->first(), 'type' => 'companion'), array('item' => Companion::where('name', 'Mickey Smith')->first(), 'type' => 'companion'), array('item' => Companion::where('name', 'River Song')->first(), 'type' => 'companion'), array('item' => Companion::where('name', 'Rory Williams')->first(), 'type' => 'companion'), array('item' => Companion::where('name', 'Rose Tyler')->first(), 'type' => 'companion'), array('item' => Companion::where('name', 'Wilfred Mott')->first(), 'type' => 'companion'), array('item' => Episode::where('season', 1)->where('episode', 1)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 1)->where('episode', 6)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 1)->where('episode', 10)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 1)->where('episode', 12)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 2)->where('episode', 5)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 2)->where('episode', 12)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 3)->where('episode', 9)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 3)->where('episode', 10)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 4)->where('episode', 4)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 4)->where('episode', 13)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 5)->where('episode', 3)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 5)->where('episode', 4)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 5)->where('episode', 12)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 6)->where('episode', 1)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 6)->where('episode', 10)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 6)->where('episode', 13)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 7)->where('episode', 5)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 7)->where('episode', 12)->first(), 'type' => 'episode'), array('item' => Episode::where('season', 8)->where('episode', 2)->first(), 'type' => 'episode'));
     $titles = array('Fabulous!', 'My favorite!', 'This stank more than anything has stunk before', 'This one put me to sleep', 'Stay away', 'Not impressed', 'Vote for Pedro', 'Cheap Wristwatch', 'I hope to see this again', 'Blew my mind', 'Ripoff', 'The old one was better', 'Better than ever');
     $comments = array("It's time to play the music. It's time to light the lights. It's time to meet the Muppets on the Muppet Show tonight. Movin' on up to the east side. We finally got a piece of the pie. Doin' it our way. There's nothing we wont try. Never heard the word impossible. This time there's no stopping us. The first mate and his Skipper too will do their very best to make the others comfortable in their tropic island nest. I have always wanted to have a neighbor just like you. I've always wanted to live in a neighborhood with you. Straightnin' the curves. Flatnin' the hills Someday the mountain might get ‘em but the law never will. Well the first thing you know ol' Jeds a millionaire. Kinfolk said Jed move away from there. black gold.\" Fish don't fry in the kitchen and beans don't burn on the grill. Took a whole lotta tryin' just to get up that hill.", "But they got diff'rent strokes. It takes diff'rent strokes - it takes diff'rent strokes to move the world. You wanna be where you can see our troubles are all the same. You wanna be where everybody knows Your name. Then one day he was shootin' at some food and up through the ground came a bubblin' crude. Oil that is It's time to put on makeup. It's time to dress up right. It's time to raise the curtain on the Muppet Show tonight. They were four men living all together yet they were all alone. Come and listen to a story about a man named Jed - a poor mountaineer barely kept his family fed. The year is 1987 and NASA launches the last of Americas deep space probes. The Brady Bunch the Brady Bunch that's the way we all became the Brady Bunch? It's time to put on makeup. It's time to dress up right. It's time to raise the curtain on the Muppet Show tonight. Here's the story of a lovely lady who was bringing up three very lovely girls. Here he comes Here comes Speed Racer. He's a demon on wheels!", "Fleeing from the Cylon tyranny the last Battlestar – Galactica - leads a rag-tag fugitive fleet on a lonely quest - a shining planet known as Earth. So lets make the most of this beautiful day. Since we're together The movie star the professor and Mary Ann here on Gilligans Isle. Wouldn't you like to get away? Sometimes you want to go where everybody knows your name. And they're always glad you came. We're gonna do it. On your mark get set and go now. Got a dream and we just know now we're gonna make our dream come true. Goodbye gray sky hello blue. There's nothing can hold me when I hold you. Feels so right it cant be wrong. Rockin' and rollin' all week long. Sunny Days sweepin' the clouds away. On my way to where the air is sweet. Can you tell me how to get how to get to Sesame Street? And if you threw a party - invited everyone you knew. You would see the biggest gift would be from me and the card attached would say thank you for being a friend. Well we're movin' on up to the east side. To a deluxe apartment in the sky. Knight Rider: A shadowy flight into the dangerous world of a man who does not exist. Believe it or not I'm walking on air. I never thought I could feel so free.", "Baby if you've ever wondered - wondered whatever became of me. I'm living on the air in Cincinnati. Cincinnati WKRP. Didn't need no welfare states. Everybody pulled his weight. Gee our old Lasalle ran great. Those were the days. And if you threw a party - invited everyone you knew. You would see the biggest gift would be from me and the card attached would say thank you for being a friend. Come and listen to a story about a man named Jed - a poor mountaineer barely kept his family fed! One two three four five six seven eight Sclemeel schlemazel hasenfeffer incorporated. black gold But they got diff'rent strokes. It takes diff'rent strokes - it takes diff'rent strokes to move the world.", "All of them had hair of gold like their mother the youngest one in curls! All of them had hair of gold like their mother the youngest one in curls. Believe it or not I'm walking on air. I never thought I could feel so free. Just two good ol' boys Never meanin' no harm. Beats all you've ever saw been in trouble with the law since the day they was born. The ship set ground on the shore of this uncharted desert isle with Gilligan the Skipper too the millionaire and his wife. Doin' it our way. Nothin's gonna turn us back now. Straight ahead and on the track now. We're gonna make our dreams come true. If you have a problem if no one else can help and if you can find them maybe you can hire The A-Team!", "If you have a problem if no one else can help and if you can find them maybe you can hire The A-Team. But they got diff'rent strokes. It takes diff'rent strokes - it takes diff'rent strokes to move the world. Now the world don't move to the beat of just one drum. What might be right for you may not be right for some.", "Were gonna do it. Give us any chance well take it. Give us any rule we'll break it. We're gonna make our dreams come true. Why do we always come here? I guess well never know. Its like a kind of torture to have to watch the show.", "black gold Why do we always come here? I guess well never know. Its like a kind of torture to have to watch the show. Here's the story of a lovely lady who was bringing up three very lovely girls. They were four men living all together yet they were all alone. Maybe you and me were never meant to be. But baby think of me once in awhile. I'm at WKRP in Cincinnati. The Brady Bunch the Brady Bunch that's the way we all became the Brady Bunch. Believe it or not I'm walking on air. I never thought I could feel so free. And we'll do it our way yes our way. Make all our dreams come true for me and you. Come and knock on our door. We've been waiting for you. Where the kisses are hers and hers and his. Three's company too? Texas tea., Till the one day when the lady met this fellow and they knew it was much more than a hunch. It's a beautiful day in this neighborhood a beautiful day for a neighbor. Would you be mine? Could you be mine? Its a neighborly day in this beautywood a neighborly day for a beauty. Would you be mine? Could you be mine. On the most sensational inspirational celebrational Muppetational… This is what we call the Muppet Show.", "The movie star the professor and Mary Ann here on Gilligans Isle. They're creepy and they're kooky mysterious and spooky. They're all together ooky the Addams Family. They call him Flipper Flipper faster than lightning. No one you see is smarter than he. The first mate and his Skipper too will do their very best to make the others comfortable in their tropic island nest. So get a witch's shawl on a broomstick you can crawl on. Were gonna pay a call on the Addams Family. Now the world don't move to the beat of just one drum. What might be right for you may not be right for some. Believe it or not I'm walking on air. I never thought I could feel so free. Flying away on a wing and a prayer. Who could it be? Believe it or not its just me. Doin' it our way. There's nothing we wont try. Never heard the word impossible. This time there's no stopping us.", "Movin' on up to the east side. We finally got a piece of the pie. Come and knock on our door. We've been waiting for you. Where the kisses are hers and hers and his. Three's company too. Just two good ol' boys Wouldn't change if they could. Fightin' the system like a true modern day Robin Hood. Space. The final frontier. These are the voyages of the Starship Enterprise. Doin' it our way. Nothin's gonna turn us back now. Straight ahead and on the track now. We're gonna make our dreams come true. Michael Knight a young loner on a crusade to champion the cause of the innocent. The helpless. The powerless in a world of criminals who operate above the law.", "Texas tea. I have always wanted to have a neighbor just like you. I've always wanted to live in a neighborhood with you? No phone no lights no motor car not a single luxury. Like Robinson Crusoe it's primitive as can be. black gold. And when the odds are against him and their dangers work to do. You bet your life Speed Racer he will see it through. we might as well say... Would you be mine? Could you be mine? Won't you be my neighbor. One two three four five six seven eight Sclemeel schlemazel hasenfeffer incorporated., It's time to put on makeup. It's time to dress up right. It's time to raise the curtain on the Muppet Show tonight!", "Goodbye gray sky hello blue. There's nothing can hold me when I hold you. Feels so right it cant be wrong. Rockin' and rollin' all week long. The mate was a mighty sailin' man the Skipper brave and sure. Five passengers set sail that day for a three hour tour a three hour tour.", "Knight Rider: A shadowy flight into the dangerous world of a man who does not exist. It's time to put on makeup. It's time to dress up right. It's time to raise the curtain on the Muppet Show tonight. The Brady Bunch the Brady Bunch that's the way we all became the Brady Bunch. Just two good ol' boys Wouldn't change if they could. Fightin' the system like a true modern day Robin Hood.", "So this is the tale of our castaways they're here for a long long time. They'll have to make the best of things its an uphill climb. It's time to play the music. It's time to light the lights. It's time to meet the Muppets on the Muppet Show tonight. It's time to put on makeup. It's time to dress up right. It's time to raise the curtain on the Muppet Show tonight. Here's the story of a lovely lady who was bringing up three very lovely girls. Baby if you've ever wondered - wondered whatever became of me. I'm living on the air in Cincinnati. Cincinnati WKRP.", "These days are all Happy and Free. These days are all share them with me oh baby. The ship set ground on the shore of this uncharted desert isle with Gilligan the Skipper too the millionaire and his wife. Believe it or not I'm walking on air. I never thought I could feel so free. Flying away on a wing and a prayer. Who could it be? Believe it or not its just me. Their house is a museum where people come to see ‘em. They really are a scream the Addams Family. And if you threw a party - invited everyone you knew. You would see the biggest gift would be from me and the card attached would say thank you for being a friend?\" Goodbye gray sky hello blue. There's nothing can hold me when I hold you. Feels so right it cant be wrong. Rockin' and rollin' all week long.");
     $users = User::get();
     // Loop through our users
     foreach ($users as $user) {
         // Loop through things to be rated
         foreach ($toComment as $item) {
             $title = $titles[rand(0, sizeof($titles) - 1)];
             $comment = $comments[rand(0, sizeof($comments) - 1)];
             Comment::create(array('user_id' => $user->id, 'item_id' => $item['item']->id, 'item_type' => $item['type'], 'title' => $title, 'content' => $comment));
         }
     }
 }
 public function run()
 {
     DB::table('companions')->delete();
     DB::table('companion_doctor')->delete();
     // Pull up the doctors to attach to companions
     $doctorNine = Doctor::where('number', 9)->first();
     $doctorTen = Doctor::where('number', 10)->first();
     $doctorEleven = Doctor::where('number', 11)->first();
     $doctorTwelve = Doctor::where('number', 12)->first();
     Companion::create(array('name' => 'Amy Pond', 'description' => 'Seven-year old Amelia Pond is visited one night by a mad man in box who eats fish fingers and custard, and who examines the frightening crack in her wall. She waits for him to return. For twelve years. When the “raggedy man” came back, Amy embarked on series of adventures with him, on the eve of her wedding to Rory Williams. The couple later travelled together, got married – an event the Doctor attended only after Amy remembered him back into existence – and had a daughter, Melody. In Amy’s own words, she went to sea and fought pirates, fell in love with a man who waited 2000 years to keep her safe, gave hope to Vincent van Gogh, and saved a whale in outer space. Touched by a Weeping Angel, Amy was catapulted back to 1938, where she lived a happy life with Rory and adopted a son.', 'image' => 'http://thedoctor.coderfaire/assets/img/companions/amy-pond.png'))->doctors()->attach([$doctorEleven->id]);
     Companion::create(array('name' => 'Captain Jack', 'description' => 'Time Agent. Torchwood Leader. Poster Boy for the Boeshane Peninsula. Over his (very) long life, Captain Jack Harkness has been many things. First meeting the Doctor and Rose in 1940s London, he helped defeat the reanimated “Empty Child” and the Slitheen, before being exterminated by the Daleks on the Game Station. Revived and made immortal by Rose Tyler after she’d absorbed the power of the Time Vortex, Jack travelled back to 1869, where his vortex manipulator burned out. Forced to live through the twentieth century, he joined Torchwood in Cardiff, knowing the Doctor would return one day to refuel on the rift. Following the TARDIS to the end of universe, Jack faced the Master, and then Davros and his Dalek crucible, as well as battling many evils on Earth with Torchwood.', 'image' => 'http://thedoctor.coderfaire/assets/img/companions/captain-jack.png'))->doctors()->attach([$doctorNine->id, $doctorTen->id]);
     Companion::create(array('name' => 'Clara Oswald', 'description' => 'That impossible girl. In Victorian London, there’s “sweet little Clara” from the Rose & Crown, who’s also an upright children’s governess. In the far-flung future, Oswin Oswald, the shipwrecked Junior Entertainments Manager from Starship Alaska, in reality a human-Dalek conversion refusing to accept her fate. Identical women, worlds and times apart, impossibly giving the Doctor the same message.', 'image' => 'http://thedoctor.coderfaire/assets/img/companions/clara-oswald.png'))->doctors()->attach([$doctorEleven->id, $doctorTwelve->id]);
     Companion::create(array('name' => 'Donna Noble', 'description' => 'A temp from West London, Donna found herself transported aboard the TARDIS as she was walking down the aisle on her wedding day. Fortunately, the Doctor saved her from marrying Lance – who’d made a deal with the Empress of the Racnoss. Despite turning down the Doctor’s offer to travel with him, she began investigating possible alien incursions, in the hope she’d meet him again. When they were reunited at Adipose Industries, she took up the offer to travel in the TARDIS - visiting Pompeii, meeting Agatha Christie and helping thwart the Sontarans. When the Doctor was exterminated by a Dalek and began regenerating he funneled the energy into his spare hand. When Donna touched this, it provoked a ‘metacrisis’, where she acquired all of the Doctor’s knowledge. Although this was essential in stopping Davros, it started to destroy Donna’s body. The Doctor was forced to wipe her mind and return her to Sylvia and Wilf. He later bought Donna and new husband Shaun a winning lottery ticket.', 'image' => 'http://thedoctor.coderfaire/assets/img/companions/donna-noble.png'))->doctors()->attach([$doctorTen->id]);
     Companion::create(array('name' => 'Martha Jones', 'description' => 'Studying for her doctorate in medicine, Martha Jones was inside Royal Hope Hospital when it was transported to the moon. Showing great bravery in the face of the Plasmavore, the Doctor invited her for travel with him. She was wooed by William Shakespeare, fought Daleks in New York and looked after the Doctor when disguised as a human school teacher in 1913. When the Doctor was captured by the Master, Martha travelled the world telling his story of resistance. The psychic energy this gathered helped release the Time Lord. After activating Project Indigo in the face of Davros\' Reality Bomb, Martha married Mickey Smith and together they hunted alien threats to Earth.', 'image' => 'http://thedoctor.coderfaire/assets/img/companions/martha-jones.png'))->doctors()->attach([$doctorTen->id]);
     Companion::create(array('name' => 'Mickey Smith', 'description' => 'On-off boyfriend of Rose Tyler, Mickey Smith was drawn into the Doctor’s world when he was captured and replicated by the Nestene Consciousness. When Rose vanished for a year with the Doctor, Mickey was questioned over her disappearance. Despite this, and getting called “Mickey the Idiot”, he helped the Doctor and Rose defeat the Slitheen, Sycorax and Krillitanes. He opted to remain in the parallel “Pete’s World” when he discovered that the parallel version of the Grandmother who raised him was a still alive. From there, he assisted Pete and Jake rid their world of Cybermen, before jumping realities and fighting the Battle of Canary Wharf. After a period of living in that world with the Tylers, he returned to his originalEarth, where he married Martha Jones.', 'image' => 'http://thedoctor.coderfaire/assets/img/companions/mickey-smith.png'))->doctors()->attach([$doctorNine->id, $doctorTen->id]);
     Companion::create(array('name' => 'River Song', 'description' => 'Born Melody Pond, to Amy Pond and Rory Williams during the Battle of Demon\'s Run, she was kidnapped by agents of The Silence and raised as the Doctor\'s perfect assassin. But in her pursuit of the Doctor, she fell in love with him, which broke her conditioning. Becoming a Doctor of Archaeology, she was again recruited by The Silence to kill the Doctor at a fixed point in time. However, the assassination was staged to allow the Doctor to disappear from view. Handed 12,000 life sentences for his murder, River spent her days at Stormcage Containment Facility, but her nights travelling with the Doctor. They investigated the wreck of the Byzantium, battled Weeping Angels in New York and visited the Singing Towers of Darillium. She died in The Library, saving the people trapped in its computer. The Doctor was able to upload her into the mainframe where her data ghost “lives” with three children to look after. (The Doctor and River have met each other, broadly speaking, in reverse order - the first time the Doctor meets River is the last time she sees him.)', 'image' => 'http://thedoctor.coderfaire/assets/img/companions/river-song.png'))->doctors()->attach([$doctorTen->id, $doctorEleven->id]);
     Companion::create(array('name' => 'Rory Williams', 'description' => 'In love with Amy Pond from his teens, Rory Williams became a nurse to try and compete with (what he thought was) her made-up friend, the Doctor. When the Doctor turned out to be real, there was initially some friction, but the two became good friends. Rory had a turbulent time in the TARDIS. He was killed by the Silurians and absorbed into a crack in time, before being resurrected as an Auton, who then killed Amy. After breaking his programming, he stood watch over her tomb in the Pandorica for 2000 years. When reality was restored, Rory ceased to be an Auton and returned to human form. While aboard the TARDIS, he and Amy became parents to Melody. Sent back in time to 1938 by a Weeping Angel, Rory lived a happy life with Amy. Their adopted son, Anthony Brian Williams, visited Rory’s father Brian in 2012, bringing a heart-breaking goodbye note from Rory.', 'image' => 'http://thedoctor.coderfaire/assets/img/companions/rory-williams.png'))->doctors()->attach([$doctorEleven->id]);
     Companion::create(array('name' => 'Rose Tyler', 'description' => 'Trapped by Autons in the basement of Henrik\'s department store, shop assistant Rose Tyler’s life is saved by a chance encounter with the Doctor. When her heroism leads to the defeat of the Nestene, he invites her to travel with him – taking her from Victorian Cardiff to the day the Earth died. And although travelling with the Doctor was often dangerous, she told him she’d stay with him forever. Witnessing the Ninth Doctor’s regeneration only made that bond stronger. However, during the Battle of Canary Wharf they were separated – trapped on parallel worlds. Using a Dimension Cannon she attempted to make contact with the Doctor (and new companion Donna) several times, eventually encountering him as he was exterminated by a Dalek. Once healed and the Daleks defeated, he returned Rose to the parallel world with her family and the half-human version of himself, to live the rest of their lives together.', 'image' => 'http://thedoctor.coderfaire/assets/img/companions/rose-tyler.png'))->doctors()->attach([$doctorNine->id, $doctorTen->id]);
     Companion::create(array('name' => 'Wilfred Mott', 'description' => 'Wilf first encountered the Doctor on Christmas Day 2007, when the Time Lord beamed down from the Titanic with Astrid Peth. A year later, during the Adipose affair, he was to see the Doctor again – this time through his telescope as the TARDIS, with Donna aboard, sped across the sky. A keen astronomer, Wilf readily accepted the Doctor\'s alien nature, along with his granddaughter\\’s travelling in time and space. When Donna\'s mind had to be wiped of her travels with the Doctor, he was heartbroken but promised to keep watching the skies for the TARDIS. Extraordinarily loyal, he urged the Doctor to kill the Master and save the world when he opened the timelock on the Time War. It was Wilf who would eventually knock four times, and herald theTenth Doctor’s regeneration.', 'image' => 'http://thedoctor.coderfaire/assets/img/companions/wilfred-mott.png'))->doctors()->attach([$doctorTen->id]);
 }
 /**
  * Declares an association between this object and a Companion object.
  *
  * @param      Companion $v
  * @return     MissionCompanion The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setCompanion(Companion $v = null)
 {
     if ($v === null) {
         $this->setCompanionId(NULL);
     } else {
         $this->setCompanionId($v->getId());
     }
     $this->aCompanion = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Companion object, it will not be re-added.
     if ($v !== null) {
         $v->addMissionCompanion($this);
     }
     return $this;
 }
Beispiel #7
0
 public function executeUpdateAjaxCompanion(sfWebRequest $request)
 {
     #security
     if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Coordinator'), false)) {
         $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer());
         $this->redirect('dashboard/index');
     }
     # id parameter is companion id which then edits
     if ($request->hasParameter('id')) {
         $cmp = CompanionPeer::retrieveByPK($request->getParameter('id'));
         $this->forward404Unless($cmp);
     } else {
         #new companion adding to existing passenger
         $cmpnnPid = $request->getParameter('campnn[passenger_id]');
         $cmp = new Companion();
         if (isset($cmpnnPid)) {
             $cmp->setPassengerId($cmpnnPid);
         } else {
             $cmp->setPassengerId($request->getParameter('passenger_id'));
         }
     }
     $this->itId = $request->getParameter('itId');
     #referer
     if ($request->hasParameter('referer')) {
         $this->referer = $request->getParameter('referer');
     } else {
         $this->referer = $request->getReferer() ? $request->getReferer() : $this->generateUrl('companion', array(), true);
     }
     $form = new CompanionForm($cmp);
     if ($request->getParameter('back')) {
         $this->back = $request->getParameter('back');
     }
     # validate and save
     if ($request->isMethod('post')) {
         $form->bind($request->getParameter($form->getName()));
         if ($form->isValid()) {
             $is_new = $form->isNew();
             if ($is_new) {
                 $person = new Person();
                 $names = explode(" ", $form->getValue('name'));
                 $person->setFirstName($names[0]);
                 if (isset($names[1])) {
                     $person->setLastName($names[1]);
                 } else {
                     $person->setLastName(NULL);
                 }
                 $person->setDayPhone($form->getValue('companion_phone'));
                 $person->setDayComment($form->getValue('companion_phone_comment'));
                 $person->save();
                 $comp = $form->getObject();
                 $comp->setName($form->getValue('name'));
                 $comp->setRelationship($form->getValue('relationship'));
                 $comp->setDateOfBirth($form->getValue('date_of_birth'));
                 $comp->setWeight($form->getValue('weight'));
                 $comp->setCompanionPhone($form->getValue('companion_phone'));
                 $comp->setCompanionPhoneComment($form->getValue('companion_phone_comment'));
                 $comp->setPersonId($person->getId());
                 $comp->save();
             } else {
                 $form->save();
             }
             $this->getUser()->setFlash('success', 'Companion has successfully ' . ($is_new ? 'created' : 'saved') . '!');
             $this->companion_saved = $form->getValue('name');
             $this->companion_id = $comp->getId();
             $this->relationship = $form->getValue('relationship');
         }
     }
     $passenger = $cmp->getPassenger();
     $this->forward404Unless($passenger);
     $this->passenger = $passenger;
     $this->form_a = $form;
     $this->cmp = $cmp;
 }
 public function run()
 {
     DB::table('episodes')->delete();
     DB::table('doctor_episode')->delete();
     DB::table('companion_episode')->delete();
     DB::table('enemy_episode')->delete();
     // Pull up doctors, companions, and enemies to attach to episodes
     $doctorNine = Doctor::where('number', 9)->first();
     $doctorTen = Doctor::where('number', 10)->first();
     $doctorEleven = Doctor::where('number', 11)->first();
     $doctorTwelve = Doctor::where('number', 12)->first();
     $cybermen = Enemy::where('name', 'Cybermen')->first();
     $daleks = Enemy::where('name', 'Daleks')->first();
     $sontarans = Enemy::where('name', 'Sontarans')->first();
     $silence = Enemy::where('name', 'The Silence')->first();
     $angels = Enemy::where('name', 'Weeping Angels')->first();
     $amy = Companion::where('name', 'Amy Pond')->first();
     $jack = Companion::where('name', 'Captain Jack')->first();
     $clara = Companion::where('name', 'Clara Oswald')->first();
     $donna = Companion::where('name', 'Donna Noble')->first();
     $martha = Companion::where('name', 'Martha Jones')->first();
     $mickey = Companion::where('name', 'Mickey Smith')->first();
     $river = Companion::where('name', 'River Song')->first();
     $rory = Companion::where('name', 'Rory Williams')->first();
     $rose = Companion::where('name', 'Rose Tyler')->first();
     $wilfred = Companion::where('name', 'Wilfred Mott')->first();
     $episode = Episode::create(array('season' => 1, 'episode' => 1, 'name' => 'Rose', 'image' => 'http://thedoctor.coderfaire/assets/img/episodes/1.1.jpg', 'description' => 'Rose Tyler believes she is living another day of her "ordinary" life, but after being threatened by Autons (living plastic) controlled by the Nestene Consciousness, she meets the Ninth Doctor.'));
     $episode->doctors()->attach([$doctorNine->id]);
     $episode->companions()->attach([$rose->id, $mickey->id]);
     $episode = Episode::create(array('season' => 1, 'episode' => 6, 'name' => 'Dalek', 'image' => 'http://thedoctor.coderfaire/assets/img/episodes/1.6.jpg', 'description' => 'The Ninth Doctor and Rose Tyler arrive in 2012 to answer a distress signal and meet a collector of alien artefacts who has one living specimen. However, the Doctor is horrified to find out that the creature is a member of a race he thought was destroyed: a Dalek.'));
     $episode->doctors()->attach([$doctorNine->id]);
     $episode->companions()->attach([$rose->id]);
     $episode->enemies()->attach([$daleks->id]);
     $episode = Episode::create(array('season' => 1, 'episode' => 10, 'name' => 'The Doctor Dances', 'image' => 'http://thedoctor.coderfaire/assets/img/episodes/1.10.jpg', 'description' => 'The Child\'s plague is spreading throughout wartime London, and its zombie army is on the march. The Ninth Doctor and Rose form an alliance with intergalactic con man Captain Jack, but find themselves trapped in the abandoned hospital. They head to the crash site of Jack\'s supposed space junk and discover the ground zero for the mysterious plague.'));
     $episode->doctors()->attach([$doctorNine->id]);
     $episode->companions()->attach([$rose->id, $jack->id]);
     $episode = Episode::create(array('season' => 1, 'episode' => 12, 'name' => 'Bad Wolf', 'image' => 'http://thedoctor.coderfaire/assets/img/episodes/1.12.jpg', 'description' => 'Separated and with no TARDIS, the Ninth Doctor, Rose, and Jack have to fight for their lives on board the Game Station, but a far more dangerous threat is lurking, just out of sight. The Doctor realises that the entire human race has been blinded to the threat on its doorstep, and Armageddon is fast approaching.'));
     $episode->doctors()->attach([$doctorNine->id]);
     $episode->companions()->attach([$rose->id, $mickey->id, $jack->id]);
     $episode->enemies()->attach([$daleks->id]);
     $episode = Episode::create(array('season' => 2, 'episode' => 5, 'name' => 'Rise of the Cybermen', 'image' => 'http://thedoctor.coderfaire/assets/img/episodes/2.5.jpg', 'description' => 'On a parallel Earth, a deadly new version of the Doctor\'s old enemy is about to be reborn.'));
     $episode->doctors()->attach([$doctorTen->id]);
     $episode->companions()->attach([$rose->id, $mickey->id]);
     $episode->enemies()->attach([$cybermen->id]);
     $episode = Episode::create(array('season' => 2, 'episode' => 12, 'name' => 'Army of Ghosts', 'image' => 'http://thedoctor.coderfaire/assets/img/episodes/2.12.jpg', 'description' => 'Rose and the Tenth Doctor return to modern-day London to find a mysterious epidemic of ghosts all over the world. As the Doctor searches Torchwood Tower to find answers, something sinister lurks in the building.'));
     $episode->doctors()->attach([$doctorTen->id]);
     $episode->companions()->attach([$rose->id, $mickey->id]);
     $episode->enemies()->attach([$daleks->id, $cybermen->id]);
     $episode = Episode::create(array('season' => 3, 'episode' => 9, 'name' => 'The Family of Blood', 'image' => 'http://thedoctor.coderfaire/assets/img/episodes/3.9.jpg', 'description' => '1913, and war comes to England a year early as the terrifying Family hunt for the Tenth Doctor.'));
     $episode->doctors()->attach([$doctorTen->id]);
     $episode->companions()->attach([$martha->id]);
     $episode = Episode::create(array('season' => 3, 'episode' => 10, 'name' => 'Blink', 'image' => 'http://thedoctor.coderfaire/assets/img/episodes/3.10.jpg', 'description' => 'In an abandoned house, the Weeping Angels wait. The only hope to stop them is a young woman named Sally Sparrow and her friend Larry Nightingale. The only catch: The Weeping Angels can move in the blink of an eye. To defeat the ruthless enemy — with only a half of a conversation from the Tenth Doctor as help — the one rule is this: don\'t turn your back, don\'t look away and don\'t blink!'));
     $episode->doctors()->attach([$doctorTen->id]);
     $episode->companions()->attach([$martha->id]);
     $episode->enemies()->attach([$angels->id]);
     $episode = Episode::create(array('season' => 4, 'episode' => 4, 'name' => 'The Sontaran Stratagem', 'image' => 'http://thedoctor.coderfaire/assets/img/episodes/4.4.png', 'description' => 'Fifty-two people across the world in eleven different time zones die at the exact same time. The only connection: they all have ATMOS installed in their vehicles. Martha Jones, now a UNIT medic, summons the Tenth Doctor back to modern-day Earth to help figure out why, but an old enemy lies in wait...'));
     $episode->doctors()->attach([$doctorTen->id]);
     $episode->companions()->attach([$martha->id, $donna->id]);
     $episode->enemies()->attach([$sontarans->id]);
     $episode = Episode::create(array('season' => 4, 'episode' => 13, 'name' => 'Journey\'s End', 'image' => 'http://thedoctor.coderfaire/assets/img/episodes/4.13.jpg', 'description' => 'All hell has broken loose! Davros and the New Dalek Empire prepare to detonate a bomb that will wipe out all of existence. The Tenth Doctor is helpless, and the TARDIS faces destruction. The only hope lies with the Doctor\'s companions — the "Children of Time" — but Dalek Caan predicts that one will die...'));
     $episode->doctors()->attach([$doctorTen->id]);
     $episode->companions()->attach([$rose->id, $donna->id, $martha->id, $jack->id, $mickey->id, $wilfred->id]);
     $episode->enemies()->attach([$daleks->id]);
     $episode = Episode::create(array('season' => 5, 'episode' => 3, 'name' => 'Victory of the Daleks', 'image' => 'http://thedoctor.coderfaire/assets/img/episodes/5.3.jpg', 'description' => 'Receiving a call for help from his old friend Winston Churchill, the Eleventh Doctor and Amy Pond head for World War II to assist the Prime Minister. Once there, though, the Doctor reunites with his greatest enemies, the scum of the universe — the Daleks. But why are these survivors of the Medusa Cascade War passing themselves off as man-made weapons? And why don\'t they recognise the Doctor? What could these "Ironsides" have planned?'));
     $episode->doctors()->attach([$doctorEleven->id]);
     $episode->companions()->attach([$amy->id]);
     $episode->enemies()->attach([$daleks->id]);
     $episode = Episode::create(array('season' => 5, 'episode' => 4, 'name' => 'The Time of Angels', 'image' => 'http://thedoctor.coderfaire/assets/img/episodes/5.4.jpg', 'description' => 'The enigmatic River Song hurtles back into the Eleventh Doctor\'s life, but she\'s not the only familiar face returning — the Weeping Angels are back! Following River\'s calling card, the Doctor is recruited to help track down the last of the Angels, which has escaped from the Byzantium starliner and into the terrifying Maze of the Dead.'));
     $episode->doctors()->attach([$doctorEleven->id]);
     $episode->companions()->attach([$amy->id, $river->id]);
     $episode->enemies()->attach([$angels->id]);
     $episode = Episode::create(array('season' => 5, 'episode' => 12, 'name' => 'The Pandorica Opens', 'image' => 'http://thedoctor.coderfaire/assets/img/episodes/5.12.jpg', 'description' => 'A Van Gogh painting ferried across thousands of years offering a terrifying prophecy, a message on the oldest cliff-face in the universe and a love that lasts a thousand years: in 102 AD England, Romans receive a surprise visit from Cleopatra. Nearby, Stonehenge hides a legendary prison-box. As it slowly unlocks from the inside, terrible forces gather in the heavens. The fates are closing around the TARDIS. The Pandorica, which contains the most dangerous threat in the Universe, is opening. Only one thing is certain: "The Pandorica will open... Silence will fall".'));
     $episode->doctors()->attach([$doctorEleven->id]);
     $episode->companions()->attach([$amy->id, $rory->id, $river->id]);
     $episode->enemies()->attach([$silence->id]);
     $episode = Episode::create(array('season' => 6, 'episode' => 1, 'name' => 'The Impossible Astronaut', 'image' => 'http://thedoctor.coderfaire/assets/img/episodes/6.1.jpg', 'description' => 'Amy Pond, Rory Williams, River Song and the Eleventh Doctor receive a mysterious summons that takes them on an adventure to 21st century Utah and Florida in 1969. Along the way they meet Richard Nixon, president of the United States of America, and former FBI agent Canton Delaware.'));
     $episode->doctors()->attach([$doctorEleven->id]);
     $episode->companions()->attach([$amy->id, $rory->id, $river->id]);
     $episode->enemies()->attach([$silence->id]);
     $episode = Episode::create(array('season' => 6, 'episode' => 10, 'name' => 'The Girl Who Waited', 'image' => 'http://thedoctor.coderfaire/assets/img/episodes/6.10.jpg', 'description' => 'The Eleventh Doctor, Rory Williams and Amy Pond land on Apalapucia in the middle of a plague. Amy is left behind, and the Doctor and Rory must save her...but time for Amy is running at a different speed.'));
     $episode->doctors()->attach([$doctorEleven->id]);
     $episode->companions()->attach([$amy->id, $rory->id]);
     $episode = Episode::create(array('season' => 6, 'episode' => 13, 'name' => 'The Wedding of River Song', 'image' => 'http://thedoctor.coderfaire/assets/img/episodes/6.13.jpg', 'description' => 'The Eleventh Doctor is prepared to meet his death at Lake Silencio. However, all of history is happening at once. What is happening and who is responsible?'));
     $episode->doctors()->attach([$doctorEleven->id]);
     $episode->companions()->attach([$amy->id, $rory->id, $river->id]);
     $episode->enemies()->attach([$silence->id]);
     $episode = Episode::create(array('season' => 7, 'episode' => 5, 'name' => 'The Angels Take Manhattan', 'image' => 'http://thedoctor.coderfaire/assets/img/episodes/7.5.jpg', 'description' => 'A simple trip to 2012 New York goes horribly wrong when the Eleventh Doctor\'s companion, Rory Williams, is sent back to the 1930s by the Weeping Angels. There, he finds that his daughter, River Song, is investigating the Angels, as Manhattan has become their hunting grounds. The Doctor and Amy Pond must find Rory before it is too late, but they soon find that not every point in time can be changed. And here, the Doctor must face the one thing he has been dreading — a final farewell to the Ponds.'));
     $episode->doctors()->attach([$doctorEleven->id]);
     $episode->companions()->attach([$amy->id, $rory->id, $river->id]);
     $episode->enemies()->attach([$angels->id]);
     $episode = Episode::create(array('season' => 7, 'episode' => 12, 'name' => 'Nightmare in Silver', 'image' => 'http://thedoctor.coderfaire/assets/img/episodes/7.12.jpg', 'description' => 'The Eleventh Doctor takes his companion, Clara Oswald, and her wards, Angie and Artie, to the biggest amusement park, Hedgewick\'s World of Wonders. The theme park is empty, occupied by a "punishment platoon" and a lone impresario with empty Cyberman shells as exhibits. The Doctor decides to stay a while, however, to investigate strange insect creatures that are roaming the park. But these insects are really machines seeking to convert the life forms on Hedgewick\'s World into the newest generation of the ever-upgrading menace...'));
     $episode->doctors()->attach([$doctorEleven->id]);
     $episode->companions()->attach([$clara->id]);
     $episode->enemies()->attach([$cybermen->id]);
     $episode = Episode::create(array('season' => 8, 'episode' => 2, 'name' => 'Into the Dalek', 'image' => 'http://thedoctor.coderfaire/assets/img/episodes/8.2.jpg', 'description' => 'Surrounded by his greatest enemies, the newest Doctor will journey into the most dangerous place in all of the universe. With the limits of his compassion being tested, the Doctor will be forced to ask a question about himself that he doesn\'t know: "Am I a good man?"'));
     $episode->doctors()->attach([$doctorTwelve->id]);
     $episode->companions()->attach([$clara->id]);
     $episode->enemies()->attach([$daleks->id]);
 }
Beispiel #9
0
 /**
  * missionRequests save all data into corresponding tables
  * CODE:mission_request_create
  */
 public function executeSave(sfWebRequest $request)
 {
     # security
     if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Coordinator'), false)) {
         $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer());
         $this->redirect('dashboard/index');
     }
     $miss_req_session = $this->getUser()->getAttribute('miss_req');
     if (!$miss_req_session) {
         return $this->forward('passenger', 'step3');
     }
     //set Requester Person
     $req_person = new Person();
     $req_person->setFirstName($miss_req_session->getReqFirstname());
     $req_person->setLastName($miss_req_session->getReqLastname());
     $req_person->setAddress1($miss_req_session->getReqAddress1());
     $req_person->setAddress2($miss_req_session->getReqAddress2());
     $req_person->setCity($miss_req_session->getReqCity());
     $req_person->setCounty($miss_req_session->getReqCounty());
     $req_person->setState($miss_req_session->getReqState());
     $req_person->setCountry($miss_req_session->getReqCountry());
     $req_person->setZipcode($miss_req_session->getReqZipcode());
     $req_person->setEmail($miss_req_session->getReqEmail());
     $req_person->setSecondaryEmail($miss_req_session->getReqSecondaryEmail());
     $req_person->setPagerEmail($miss_req_session->getReqPagerEmail());
     $req_person->setDayPhone($miss_req_session->getReqDayPhone());
     $req_person->setDayComment($miss_req_session->getReqDayComment());
     $req_person->setEveningPhone($miss_req_session->getReqEvePhone());
     $req_person->setEveningComment($miss_req_session->getReqEveComment());
     $req_person->setMobilePhone($miss_req_session->getReqMobilePhone());
     $req_person->setMobileComment($miss_req_session->getReqMobileComment());
     $req_person->setPagerPhone($miss_req_session->getReqPagerPhone());
     $req_person->setPagerComment($miss_req_session->getReqPagerComment());
     $req_person->setOtherPhone($miss_req_session->getReqOtherPhone());
     $req_person->setOtherComment($miss_req_session->getReqOtherComment());
     $req_person->save();
     //end of Requester Person
     // set Requester Agency
     $agency = AgencyPeer::getByNamePhone(trim($miss_req_session->getAgencyName()));
     if ($agency) {
         # nothing
     } else {
         $agency = new Agency();
         $agency->setName(trim($miss_req_session->getAgencyName()));
         $agency->save();
     }
     //set Requester
     $requester = new Requester();
     $requester->setPersonId($req_person->getId());
     $requester->setAgencyId($agency->getId());
     //$requester->setDischarge($miss_req_session->getReqDischarge());
     $requester->save();
     if (isset($miss_req_session->passenger_id)) {
         $passenger = PassengerPeer::retrieveByPK($miss_req_session->passenger_id);
         if (!$passenger instanceof Passenger) {
             $passenger = new Passenger();
         }
     } else {
         $passenger = new Passenger();
     }
     if ($passenger->isNew()) {
         $person = new Person();
     } else {
         $person = $passenger->getPerson();
     }
     //set Person to Passenger
     $person->setTitle($miss_req_session->getPassTitle());
     $person->setFirstName($miss_req_session->getPassFirstName());
     $person->setLastName($miss_req_session->getPassLastName());
     $person->setGender($miss_req_session->getPassGender());
     $person->setAddress1($miss_req_session->getPassAddress1());
     $person->setAddress2($miss_req_session->getPassAddress2());
     $person->setCity($miss_req_session->getPassCity());
     $person->setState($miss_req_session->getPassState());
     $person->setZipcode($miss_req_session->getPassZipcode());
     $person->setCountry($miss_req_session->getPassCountry());
     $person->setEmail($miss_req_session->getPassEmail());
     $person->setDayPhone($miss_req_session->getPassDayPhone());
     $person->setDayComment($miss_req_session->getPassDayComment());
     $person->setEveningPhone($miss_req_session->getPassEvePhone());
     $person->setEveningComment($miss_req_session->getPassEveComment());
     $person->setMobilePhone($miss_req_session->getPassMobilePhone());
     $person->setMobileComment($miss_req_session->getPassMobileComment());
     $person->setPagerPhone($miss_req_session->getPassPagerPhone());
     $person->setPagerComment($miss_req_session->getPassPagerComment());
     $person->setOtherPhone($miss_req_session->getPassOtherPhone());
     $person->setOtherComment($miss_req_session->getPassOtherComment());
     $person->save();
     //set Passenger
     $passenger->setPersonId($person->getId());
     $passenger->setPassengerTypeId($miss_req_session->getPassType());
     $passenger->setDateOfBirth($miss_req_session->getPassDateOfBirth());
     $passenger->setIllness($miss_req_session->getIllness());
     $passenger->setFinancial($miss_req_session->getFinancial());
     $passenger->setPublicConsiderations($miss_req_session->getPassPublicCons());
     $passenger->setPrivateConsiderations($miss_req_session->getPassPrivateCons());
     $passenger->setReleasingPhysician($miss_req_session->getReleasingPhysician());
     $passenger->setReleasingPhone($miss_req_session->getReleasePhone());
     $passenger->setReleasingFax1($miss_req_session->getReleaseFax());
     $passenger->setReleasingFax1Comment($miss_req_session->getReleaseFaxComment());
     $passenger->setLodgingName($miss_req_session->getLodgingName());
     $passenger->setLodgingPhone($miss_req_session->getLodgingPhone());
     $passenger->setLodgingPhoneComment($miss_req_session->getLodgingPhoneComment());
     $passenger->setFacilityName($miss_req_session->getFacilityName());
     $passenger->setFacilityPhone($miss_req_session->getFacilityPhone());
     $passenger->setFacilityPhoneComment($miss_req_session->getFacilityPhoneComment());
     $passenger->setReleasingEmail($miss_req_session->getReleaseEmail());
     $passenger->setTreatingPhysician($miss_req_session->getTreatingPhysician());
     $passenger->setTreatingPhone($miss_req_session->getTreatingPhone());
     $passenger->setTreatingFax1($miss_req_session->getTreatingFax());
     $passenger->setTreatingFax1Comment($miss_req_session->getTreatingFaxComment());
     $passenger->setTreatingEmail($miss_req_session->getTreatingEmail());
     $passenger->setLanguageSpoken($miss_req_session->getPassLanguage());
     $passenger->setBestContactMethod($miss_req_session->getBestContact());
     $passenger->setEmergencyContactName($miss_req_session->getEmergencyName());
     $passenger->setEmergencyContactPrimaryPhone($miss_req_session->getEmergencyPhone1());
     $passenger->setEmergencyContactPrimaryComment($miss_req_session->getEmergencyPhone1Comment());
     $passenger->setEmergencyContactSecondaryPhone($miss_req_session->getEmergencyPhone2());
     $passenger->setEmergencyContactSecondaryComment($miss_req_session->getEmergencyPhone2Comment());
     $passenger->setNeedMedicalRelease($miss_req_session->getPassMedical());
     $passenger->save();
     //set Companions
     if ($passenger && $miss_req_session->getCom1Name()) {
         $person = new Person();
         $names[] = split(" ", $miss_req_session->getCom1Name());
         //echo var_dump($names); die();
         $person->setFirstName($names[0][0]);
         $person->setLastName($names[0][1]);
         $person->setDayPhone($miss_req_session->getCom1Phone());
         $person->setDayComment($miss_req_session->getCom1Comment());
         $person->save();
         $companion = new Companion();
         $companion->setPassengerId($passenger->getId());
         $companion->setName($miss_req_session->getCom1Name());
         $companion->setRelationship($miss_req_session->getCom1Relationship());
         $companion->setDateOfBirth($miss_req_session->getCom1DateOfBirth());
         $companion->setWeight($miss_req_session->getCom1Weigth());
         $companion->setCompanionPhone($miss_req_session->getCom1Phone());
         $companion->setCompanionPhoneComment($miss_req_session->getCom1Comment());
         $companion->setPersonId($person->getId());
         $companion->save();
     }
     if ($passenger && $miss_req_session->getCom2Name()) {
         $person = new Person();
         $names[] = split(" ", $miss_req_session->getCom2Name());
         //echo var_dump($names); die();
         $person->setFirstName($names[0][0]);
         $person->setLastName($names[0][1]);
         $person->setDayPhone($miss_req_session->getCom2Phone());
         $person->setDayComment($miss_req_session->getCom2Comment());
         $person->save();
         $companion = new Companion();
         $companion->setPassengerId($passenger->getId());
         $companion->setName($miss_req_session->getCom2Name());
         $companion->setRelationship($miss_req_session->getCom2Relationship());
         $companion->setDateOfBirth($miss_req_session->getCom2DateOfBirth());
         $companion->setWeight($miss_req_session->getCom2Weigth());
         $companion->setCompanionPhone($miss_req_session->getCom2Phone());
         $companion->setCompanionPhoneComment($miss_req_session->getCom2Comment());
         $companion->setPersonId($person->getId());
         $companion->save();
     }
     if ($passenger && $miss_req_session->getCom3Name()) {
         $person = new Person();
         $names[] = split(" ", $miss_req_session->getCom3Name());
         //echo var_dump($names); die();
         $person->setFirstName($names[0][0]);
         $person->setLastName($names[0][1]);
         $person->setDayPhone($miss_req_session->getCom3Phone());
         $person->setDayComment($miss_req_session->getCom3Comment());
         $person->save();
         $companion = new Companion();
         $companion->setPassengerId($passenger->getId());
         $companion->setName($miss_req_session->getCom3Name());
         $companion->setRelationship($miss_req_session->getCom3Relationship());
         $companion->setDateOfBirth($miss_req_session->getCom3DateOfBirth());
         $companion->setWeight($miss_req_session->getCom3Weigth());
         $companion->setCompanionPhone($miss_req_session->getCom3Phone());
         $companion->setCompanionPhoneComment($miss_req_session->getCom3Comment());
         $companion->setPersonId($person->getId());
         $companion->save();
     }
     if ($passenger && $miss_req_session->getCom4Name()) {
         $person = new Person();
         $names[] = split(" ", $miss_req_session->getCom4Name());
         //echo var_dump($names); die();
         $person->setFirstName($names[0][0]);
         $person->setLastName($names[0][1]);
         $person->setDayPhone($miss_req_session->getCom4Phone());
         $person->setDayComment($miss_req_session->getCom4Comment());
         $person->save();
         $companion = new Companion();
         $companion->setPassengerId($passenger->getId());
         $companion->setName($miss_req_session->getCom4Name());
         $companion->setRelationship($miss_req_session->getCom4Relationship());
         $companion->setDateOfBirth($miss_req_session->getCom4DateOfBirth());
         $companion->setWeight($miss_req_session->getCom4Weigth());
         $companion->setCompanionPhone($miss_req_session->getCom4Phone());
         $companion->setCompanionPhoneComment($miss_req_session->getCom4Comment());
         $companion->setPersonId($person->getId());
         $companion->save();
     }
     if ($passenger && $miss_req_session->getCom5Name()) {
         $person = new Person();
         $names[] = split(" ", $miss_req_session->getCom5Name());
         //echo var_dump($names); die();
         $person->setFirstName($names[0][0]);
         $person->setLastName($names[0][1]);
         $person->setDayPhone($miss_req_session->getCom5Phone());
         $person->setDayComment($miss_req_session->getCom5Comment());
         $person->save();
         $companion = new Companion();
         $companion->setPassengerId($passenger->getId());
         $companion->setName($miss_req_session->getCom5Name());
         $companion->setRelationship($miss_req_session->getCom5Relationship());
         $companion->setDateOfBirth($miss_req_session->getCom5DateOfBirth());
         $companion->setWeight($miss_req_session->getCom5Weigth());
         $companion->setCompanionPhone($miss_req_session->getCom5Phone());
         $companion->setCompanionPhoneComment($miss_req_session->getCom5Comment());
         $companion->setPersonId($person->getId());
         $companion->save();
     }
     //set Itinerary
     $itinerary = ItineraryPeer::getByMissReqId($miss_req_session->getId());
     if (!$itinerary) {
         $new_itinerary = new Itinerary();
         $new_itinerary->setDateRequested(date('m/d/Y'));
         $new_itinerary->setMissionRequestId($miss_req_session->getId());
         $new_itinerary->setMissionTypeId($miss_req_session->getMissionRequestTypeId());
         $new_itinerary->setApointTime($miss_req_session->getApptDate());
         $new_itinerary->setPassengerId($passenger->getId());
         $new_itinerary->setRequesterId($requester->getId());
         $new_itinerary->setFacility($miss_req_session->getFacilityName());
         $new_itinerary->setLodging($miss_req_session->getLodgingName());
         $new_itinerary->setOrginCity($miss_req_session->getOrginCity());
         $new_itinerary->setOrginState($miss_req_session->getOrginState());
         $new_itinerary->setDestCity($miss_req_session->getDestCity());
         $new_itinerary->setDestState($miss_req_session->getDestState());
         $new_itinerary->setWaiverNeed(0);
         $new_itinerary->setNeedMedicalRelease($miss_req_session->getPassMedical());
         $new_itinerary->setComment($miss_req_session->getComment());
         $new_itinerary->setAgencyId($agency->getId());
         $new_itinerary->save();
     }
     //set default Mission to Mission table
     //get Passenger
     //$passenger = PassengerPeer::getByPersonId($person->getId());
     $misson = new Mission();
     $misson->setRequestId($miss_req_session->getId());
     $misson->setItineraryId($new_itinerary->getId());
     $misson->setMissionTypeId($miss_req_session->getMissionRequestTypeId());
     $misson->setDateRequested($miss_req_session->getRequesterDate());
     if ($passenger) {
         $misson->setPassengerId($passenger->getId());
     }
     if ($requester) {
         $misson->setRequesterId($requester->getId());
     }
     if ($agency) {
         $misson->setAgencyId($agency->getId());
     }
     // Farazi Mission 1 externa ID
     $c = new Criteria();
     $c->add(MissionPeer::EXTERNAL_ID, NULL, Criteria::ISNOTNULL);
     $c->addDescendingOrderByColumn(MissionPeer::ID);
     $external_mission = MissionPeer::doSelectOne($c);
     $external_id = $external_mission->getExternalId();
     $currentExternalId = $external_id + 1;
     $misson->setExternalId($currentExternalId);
     $misson->setApptDate($miss_req_session->getApptDate());
     $misson->setFlightTime($miss_req_session->getFlightTime());
     $misson->setMissionDate($miss_req_session->getMissionDate());
     $misson->setMissionCount(1);
     $misson->save();
     $missLeg = new MissionLeg();
     $missLeg->setMissionId($misson->getId());
     $missLeg->setLegNumber(1);
     if ($miss_req_session->getOrginState() && $miss_req_session->getOrginZipcode()) {
         //echo $miss_req_session->getOrginState().'-'.$miss_req_session->getOrginZipcode();die();
         $fromairport = AirportPeer::getAirportByStateAndZipcode($miss_req_session->getOrginState(), $miss_req_session->getOrginZipcode());
         if ($fromairport) {
             $missLeg->setFromAirportId($fromairport->getId());
         }
     }
     if ($miss_req_session->getDestState() && $miss_req_session->getDestZipcode()) {
         //echo $miss_req_session->getDestState().'--'.$miss_req_session->getDestZipcode();die();
         $toairport = AirportPeer::getAirportByStateAndZipcode($miss_req_session->getDestState(), $miss_req_session->getDestZipcode());
         if ($toairport) {
             $missLeg->setToAirportId($toairport->getId());
         }
     }
     //echo "oder";die();
     $missLeg->setPassOnBoard(0);
     $missLeg->setWebCoordinated(0);
     $missLeg->setTransportation('air_mission');
     $missLeg->save();
     //end set Mission
     $this->getUser()->setFlash('success', 'New mission has successfully created!');
     $miss_req_session->setProcessedDate(time());
     $miss_req_session->save();
     $this->getUser()->setAttribute('miss_req', null);
     //$this->redirect('miss_req');
     //$this->getUser()->setFlash('success',$success);
     //$request->getParameter('back')
     $this->redirect('/itinerary/detail/' . $new_itinerary->getId());
 }
Beispiel #10
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      Companion $value A Companion object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(Companion $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Beispiel #11
0
 public function executeAjaxNew(sfWebRequest $request)
 {
     if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Coordinator'), false)) {
         $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer());
         $this->redirect('dashboard/index');
     }
     $companion = new Companion();
     $companion->setPassengerId($request->getParameter('passenger_id'));
     $this->form = new CompanionForm($companion);
     $this->el_id = $request->getParameter('el_id');
 }