diff --git a/app/database/migrations/2013_11_09_184814_system.php b/app/database/migrations/2013_11_09_184814_system.php new file mode 100644 index 0000000..11036f3 --- /dev/null +++ b/app/database/migrations/2013_11_09_184814_system.php @@ -0,0 +1,31 @@ +increments('id'); + $table->integer('nextfilm'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('system'); + } + +} \ No newline at end of file diff --git a/app/models/Comment.php b/app/models/Comment.php index 9115d18..69047fe 100644 --- a/app/models/Comment.php +++ b/app/models/Comment.php @@ -7,7 +7,11 @@ class Comment extends Eloquent { return $this->belongsTo('User', 'user'); } - public function film() { + public function objekt() { return $this->belongsTo('Film', 'film'); } + + public function scopeNeueste($query) { + return $query->orderBy('updated_at', 'DESC')->take(5); + } } \ No newline at end of file diff --git a/app/models/Dumbo.php b/app/models/Dumbo.php new file mode 100644 index 0000000..cc4346b --- /dev/null +++ b/app/models/Dumbo.php @@ -0,0 +1,13 @@ +belongsTo('Film', 'nextfilm'); + } + + public function scopeNextFilm($query) { + return $query->find(1); + } +} \ No newline at end of file diff --git a/app/routes.php b/app/routes.php index da5fef7..dde7c97 100644 --- a/app/routes.php +++ b/app/routes.php @@ -16,6 +16,7 @@ Route::get('/', function() $gesehen = Film::zuletztGesehen()->get(); $vorgeschlagen = Film::neuesteVorschlage()->get(); $news = News::aktuell()->get(); + $nextfilm = Dumbo::find(1)->film; $topfilm = DB::table(DB::raw('film_films')) ->select(DB::raw('film_films.*, COUNT(case when film_votes.stimme IS TRUE then 1 end) as upvotes, @@ -23,6 +24,7 @@ Route::get('/', function() COUNT(case when film_votes.stimme IS TRUE then 1 end) - COUNT(case when film_votes.stimme IS FALSE then 1 end) as vcount')) ->leftJoin('votes', 'votes.film', '=', 'films.id') ->whereNull('films.gesehen') + ->where('films.id', "!=", is_object($nextfilm) ? $nextfilm->id : 0) ->groupBy('id') ->orderBy('vcount', 'DESC')->orderBy('vorgeschlagen', 'ASC') ->first(); @@ -31,11 +33,23 @@ Route::get('/', function() $tmovie = $tmdb->getMovie($topfilm->tvdbid); $image = $tmdb->getImageUrl($tmovie['poster_path'], TMDb::IMAGE_POSTER, 'w342'); + if(is_object($nextfilm)) { + $tmovie = $tmdb->getMovie($nextfilm->tvdbid); + $nimage = $tmdb->getImageUrl($tmovie['poster_path'], TMDb::IMAGE_POSTER, 'w342'); + } else { + $nimage = "http://d3a8mw37cqal2z.cloudfront.net/assets/7ea4ac6f271e37d/images/no-poster-w130.jpg"; + } + + $kommentare = Comment::neueste()->get(); + return View::make('index') ->with('gesehen', $gesehen) ->with('vorgeschlagen', $vorgeschlagen) ->with('image', $image) + ->with('nimage', $nimage) ->with('news', $news) + ->with('kommentare', $kommentare) + ->with('nextfilm', $nextfilm) ->with('topfilm', $topfilm); }); @@ -201,9 +215,21 @@ Route::get('mark-read/{id}', array('before' => 'auth', function($id) { $film = Film::findOrFail($id); $film->gesehen = \Carbon\Carbon::today(); $film->save(); + if(Dumbo::find(1)->nextfilm == $film->id) { + $system = Dumbo::findOrFail(1); + $system->nextfilm = 0; + $system->save(); + } return Redirect::to('film/' . $film->id); })); +Route::get('view-next/{id}', array('before' => 'auth', function($id) { + $system = Dumbo::findOrFail(1); + $system->nextfilm = $id; + $system->save(); + return Redirect::to('film/' . $id); +})); + Route::get('register', function() { return View::make('register'); }); diff --git a/app/views/film.blade.php b/app/views/film.blade.php index 2b42ab7..c74ad1a 100644 --- a/app/views/film.blade.php +++ b/app/views/film.blade.php @@ -233,7 +233,7 @@ placement: "right", trigger: "click", title: "Als gesehen markieren", - content: "
" + content: "" }); }); diff --git a/app/views/index.blade.php b/app/views/index.blade.php index 5c4b230..53122dd 100644 --- a/app/views/index.blade.php +++ b/app/views/index.blade.php @@ -3,13 +3,16 @@ @section('content'){{$topfilm->upvotes}} {{$topfilm->downvotes}}
+ @if(!is_null(Auth::user()) && Auth::user()->admin) + id) }}' class='btn btn-success btn-xs'>Als nächstes sehen + @endifDie neuesten Vorschläge für den nächsten Filmabend. Klicke einen der Vorschläge an, um Filmdetails zu sehen und darüber abzustimmen.
Die Filme, die wir kürzlich gesehen haben. Klicke einen der Titel an, um Kommentare und Filmdetails sowie ein etwaiges Abstimmungsergebnis zu sehen.
+ {{ substr($kommentar->text, 0, 55)}}text) > 55) echo "..." ?> +
+ @endforeach