11.08.2017 Views

codebright

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Build An App 1: Playstation Game Collection 381<br />

15 public function create()<br />

16 {<br />

17 // Show the create game form.<br />

18 return View::make('create');<br />

19 }<br />

20<br />

21 public function handleCreate()<br />

22 {<br />

23 // Handle create form submission.<br />

24 $game = new Game;<br />

25 $game->title = Input::get('title');<br />

26 $game->publisher = Input::get('publisher');<br />

27 $game->complete = Input::has('complete');<br />

28 $game->save();<br />

29<br />

30 return Redirect::action('GamesController@index');<br />

31 }<br />

32<br />

33 public function edit(Game $game)<br />

34 {<br />

35 // Show the edit game form.<br />

36 return View::make('edit', compact('game'));<br />

37 }<br />

38<br />

39 public function handleEdit()<br />

40 {<br />

41 // Handle edit form submission.<br />

42 $game = Game::findOrFail(Input::get('id'));<br />

43 $game->title = Input::get('title');<br />

44 $game->publisher = Input::get('publisher');<br />

45 $game->complete = Input::has('complete');<br />

46 $game->save();<br />

47<br />

48 return Redirect::action('GamesController@index');<br />

49 }<br />

50<br />

51 public function delete(Game $game)<br />

52 {<br />

53 // Show delete confirmation page.<br />

54 return View::make('delete', compact('game'));<br />

55 }<br />

56

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!