From 114e658b7bb30d3cdd2af222436841ea753881ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20M=C3=BCllers?= Date: Sat, 9 Nov 2013 21:23:58 +0100 Subject: [PATCH] Neues Update --- .../migrations/2013_11_09_184814_system.php | 31 +++++++ app/models/Comment.php | 6 +- app/models/Dumbo.php | 13 +++ app/routes.php | 26 ++++++ app/views/film.blade.php | 2 +- app/views/index.blade.php | 85 ++++++++++++++----- app/views/suggest.blade.php | 22 ++++- 7 files changed, 157 insertions(+), 28 deletions(-) create mode 100644 app/database/migrations/2013_11_09_184814_system.php create mode 100644 app/models/Dumbo.php 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: "
id) }}' class='btn btn-success'>Film als gesehen markieren
" + content: "
id) }}' class='btn btn-success'>Gesehenid) }}' class='btn btn-warning'>Als nächstes sehen
" }); }); 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')
-
+
Meistgewünschter Film

{{$topfilm->name}}

 {{$topfilm->upvotes}}  {{$topfilm->downvotes}}

+ @if(!is_null(Auth::user()) && Auth::user()->admin) + id) }}' class='btn btn-success btn-xs'>Als nächstes sehen + @endif
@@ -18,6 +21,52 @@
+
+
+
Nächster Film
+
+ +

{{is_object($nextfilm) ? $nextfilm->name : "Steht nicht fest"}}

+ @if(is_object($nextfilm)) id) }}' class='btn btn-success btn-xs'>Gesehen + @endif +
+ + @if(is_object($nextfilm)) +
+ {{ link_to_route('film', "Filmdetails", array($nextfilm->id), array('class' => 'list-group-item'))}} +
+ @endif +
+
+ + +
+ +
+
+
+
Neue Vorschläge
+ +
+ @foreach ($vorgeschlagen as $film) + {{ link_to_route('film', $film->name, array($film->id), array('class' => 'list-group-item'))}} + @endforeach +
+
+
+
+
+
Gesehene Filme
+ +
+ @foreach ($gesehen as $film) + {{ link_to_route('film', $film->name, array($film->id), array('class' => 'list-group-item'))}} + @endforeach +
+
+
+
+
@foreach ($news as $new) @@ -35,32 +84,24 @@ @endforeach
-
- -
-
-
Neue Vorschläge
-

Die neuesten Vorschläge für den nächsten Filmabend. Klicke einen der Vorschläge an, um Filmdetails zu sehen und darüber abzustimmen.

- +
+
Letzte Kommentare
+
- @foreach ($vorgeschlagen as $film) - {{ link_to_route('film', $film->name, array($film->id), array('class' => 'list-group-item'))}} - @endforeach -
-
-
-
-
-
Gesehene Filme
-

Die Filme, die wir kürzlich gesehen haben. Klicke einen der Titel an, um Kommentare und Filmdetails sowie ein etwaiges Abstimmungsergebnis zu sehen.

- -
- @foreach ($gesehen as $film) - {{ link_to_route('film', $film->name, array($film->id), array('class' => 'list-group-item'))}} + @foreach ($kommentare as $kommentar) + film) }}" class="list-group-item"> +
{{$kommentar->autor->name}} + in {{ $kommentar->objekt->name }} +
+

+ {{ substr($kommentar->text, 0, 55)}}text) > 55) echo "..." ?> +

+
@endforeach
+ @stop \ No newline at end of file diff --git a/app/views/suggest.blade.php b/app/views/suggest.blade.php index f4ada6c..35e7558 100644 --- a/app/views/suggest.blade.php +++ b/app/views/suggest.blade.php @@ -14,18 +14,32 @@ @foreach($filme as $film) - {{ HTML::link('film/' . $film->id, $film->name) }} + + id)->where('user', Auth::user()->id)->count()) + $stimme = Vote::where('film', $film->id)->where('user', Auth::user()->id)->first()->stimme; + ?> + {{ HTML::link('film/' . $film->id, $film->name) }} + upvotes; $np = $film->downvotes; - ?> - + ?>  {{ $vp }},  {{ $np }} - +" . ($vp - $np) : "danger'>".($vp - $np) }} + @if(($vp - $np) > 0) +{{$vp - $np}} + @elseif(($vp - $np) < 0) {{$vp - $np}} + @else {{$vp - $np}} + @endif + @if($stimme == 1) +   + @elseif($stimme == 0) +   + @endif {{ \Carbon\Carbon::parse($film->vorgeschlagen)->format('d.m.Y')}} {{ Film::find($film->id)->besitzer->name }}