routes.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /*
  3. |--------------------------------------------------------------------------
  4. | Application Routes
  5. |--------------------------------------------------------------------------
  6. |
  7. | Here is where you can register all of the routes for an application.
  8. | It's a breeze. Simply tell Laravel the URIs it should respond to
  9. | and give it the Closure to execute when that URI is requested.
  10. |
  11. */
  12. Route::get('/', function()
  13. {
  14. $gesehen = Film::zuletztGesehen()->get();
  15. $vorgeschlagen = Film::neuesteVorschlage()->get();
  16. return View::make('index')
  17. ->with('gesehen', $gesehen)
  18. ->with('vorgeschlagen', $vorgeschlagen);
  19. });
  20. Route::get('film/{id}', array('as' => 'film', function($id) {
  21. $film = Film::findOrFail($id);
  22. $tmdb = new TMDb('b187f8d9c5e72b1faecb741d5d04239a', 'de', TRUE);
  23. $tmovie = $tmdb->getMovie($film->tvdbid);
  24. $tcast = $tmdb->getMovieCast($film->tvdbid);
  25. $ttrail = $tmdb->getMovieTrailers($film->tvdbid);
  26. $image = $tmdb->getImageUrl($tmovie['poster_path'], TMDb::IMAGE_POSTER, 'w342');
  27. $votes = $film->votes()->count();
  28. $vposi = $film->votes()->where('stimme', true)->count();
  29. $comments = $film->comments()->orderBy('id', 'DESC')->get();
  30. return View::make('film')
  31. ->with('film', $film)
  32. ->with('tfilm', $tmovie)
  33. ->with('poster', $image)
  34. ->with('comments', $comments)
  35. ->with('cast', $tcast)
  36. ->with('trail', $ttrail)
  37. ->with('votes', $votes)
  38. ->with('vposi', $vposi)
  39. ->with('tmdb', $tmdb);
  40. }));
  41. Route::get('login', array('as' => 'login', function() {
  42. return View::make('login');
  43. }));
  44. Route::post('login', function() {
  45. $userdata = array(
  46. 'name' => Input::get('iSpieler'),
  47. 'password' => Input::get('iPassword'));
  48. if(Auth::attempt($userdata)) {
  49. return Redirect::intended('/');
  50. } else {
  51. echo "Login gescheitert.";
  52. var_dump($userdata);
  53. return Redirect::to('login')
  54. ->with('login_errors', true);
  55. }
  56. });
  57. Route::get('logout', array('as' => 'logout', function() {
  58. Auth::logout();
  59. return Redirect::to('/');
  60. }));