Neues Update
This commit is contained in:
31
app/database/migrations/2013_11_09_184814_system.php
Normal file
31
app/database/migrations/2013_11_09_184814_system.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class System extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('system', function($table) {
|
||||
$table->increments('id');
|
||||
$table->integer('nextfilm');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('system');
|
||||
}
|
||||
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
13
app/models/Dumbo.php
Normal file
13
app/models/Dumbo.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
class Dumbo extends Eloquent {
|
||||
protected $table = "system";
|
||||
|
||||
public function film() {
|
||||
return $this->belongsTo('Film', 'nextfilm');
|
||||
}
|
||||
|
||||
public function scopeNextFilm($query) {
|
||||
return $query->find(1);
|
||||
}
|
||||
}
|
@@ -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');
|
||||
});
|
||||
|
@@ -233,7 +233,7 @@
|
||||
placement: "right",
|
||||
trigger: "click",
|
||||
title: "Als gesehen markieren",
|
||||
content: "<div class='container'><a href='{{ url('mark-read/' . $film->id) }}' class='btn btn-success'>Film als gesehen markieren</a></div>"
|
||||
content: "<div class='container'><a href='{{ url('mark-read/' . $film->id) }}' class='btn btn-success'>Gesehen</a><a href='{{ url('view-next/' . $film->id) }}' class='btn btn-warning'>Als nächstes sehen</a></div>"
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
@@ -3,13 +3,16 @@
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel panel-info">
|
||||
<div class="panel-heading">Meistgewünschter Film</div>
|
||||
<div class="panel-body">
|
||||
<img src="{{$image}}" class="pull-left thumbnail" style="max-height: 100px; margin-right: 15px;">
|
||||
<h4>{{$topfilm->name}}</h4>
|
||||
<p><span class="glyphicon glyphicon-thumbs-up"></span> {{$topfilm->upvotes}}
|
||||
<span class="glyphicon glyphicon-thumbs-down"></span> {{$topfilm->downvotes}}</p>
|
||||
@if(!is_null(Auth::user()) && Auth::user()->admin)
|
||||
<a href='{{ url('view-next/' . $topfilm->id) }}' class='btn btn-success btn-xs'>Als nächstes sehen</a>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<div class="list-group">
|
||||
@@ -18,6 +21,52 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">Nächster Film</div>
|
||||
<div class="panel-body">
|
||||
<img src="{{$nimage}}" class="pull-left thumbnail" style="max-height: 100px; margin-right: 15px;">
|
||||
<h4>{{is_object($nextfilm) ? $nextfilm->name : "Steht nicht fest"}}</h4>
|
||||
@if(is_object($nextfilm)) <a href='{{ url('mark-read/' . $nextfilm->id) }}' class='btn btn-success btn-xs'>Gesehen</a>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@if(is_object($nextfilm))
|
||||
<div class="list-group">
|
||||
{{ link_to_route('film', "Filmdetails", array($nextfilm->id), array('class' => 'list-group-item'))}}
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="panel panel-success">
|
||||
<div class="panel-heading">Neue Vorschläge</div>
|
||||
|
||||
<div class="list-group">
|
||||
@foreach ($vorgeschlagen as $film)
|
||||
{{ link_to_route('film', $film->name, array($film->id), array('class' => 'list-group-item'))}}
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="panel panel-danger">
|
||||
<div class="panel-heading">Gesehene Filme</div>
|
||||
|
||||
<div class="list-group">
|
||||
@foreach ($gesehen as $film)
|
||||
{{ link_to_route('film', $film->name, array($film->id), array('class' => 'list-group-item'))}}
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="panel-group" id="accordion">
|
||||
@foreach ($news as $new)
|
||||
@@ -35,32 +84,24 @@
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="panel panel-success">
|
||||
<div class="panel-heading">Neue Vorschläge</div>
|
||||
<div class="panel-body"><p>Die neuesten Vorschläge für den nächsten Filmabend. Klicke einen der Vorschläge an, um Filmdetails zu sehen und darüber abzustimmen.</p></div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Letzte Kommentare</div>
|
||||
|
||||
<div class="list-group">
|
||||
@foreach ($vorgeschlagen as $film)
|
||||
{{ link_to_route('film', $film->name, array($film->id), array('class' => 'list-group-item'))}}
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">Gesehene Filme</div>
|
||||
<div class="panel-body"><p>Die Filme, die wir kürzlich gesehen haben. Klicke einen der Titel an, um Kommentare und Filmdetails sowie ein etwaiges Abstimmungsergebnis zu sehen.</p></div>
|
||||
|
||||
<div class="list-group">
|
||||
@foreach ($gesehen as $film)
|
||||
{{ link_to_route('film', $film->name, array($film->id), array('class' => 'list-group-item'))}}
|
||||
@foreach ($kommentare as $kommentar)
|
||||
<a href="{{ url("film/" . $kommentar->film) }}" class="list-group-item">
|
||||
<h6 class='list-group-item-heading'>{{$kommentar->autor->name}}
|
||||
<small>in {{ $kommentar->objekt->name }}</small>
|
||||
</h6>
|
||||
<p class='list-group-item-text'>
|
||||
{{ substr($kommentar->text, 0, 55)}}<?php if(strlen($kommentar->text) > 55) echo "..." ?>
|
||||
</p>
|
||||
</a>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@stop
|
@@ -14,18 +14,32 @@
|
||||
</tr>
|
||||
@foreach($filme as $film)
|
||||
<tr>
|
||||
<td>{{ HTML::link('film/' . $film->id, $film->name) }}</td>
|
||||
<td>
|
||||
<?php
|
||||
$stimme = 2;
|
||||
if(!is_null(Auth::user()) && Vote::where('film', $film->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) }}
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
$vp = $film->upvotes;
|
||||
$np = $film->downvotes;
|
||||
?>
|
||||
|
||||
?>
|
||||
<span class="glyphicon glyphicon-thumbs-up"></span> {{ $vp }},
|
||||
<span class="glyphicon glyphicon-thumbs-down"></span> {{ $np }}
|
||||
</td>
|
||||
<td>
|
||||
<span class='label label-{{ ($vp - $np) > 0 ? "success'>+" . ($vp - $np) : "danger'>".($vp - $np) }}</span>
|
||||
@if(($vp - $np) > 0) <span class="label label-success">+{{$vp - $np}}</span>
|
||||
@elseif(($vp - $np) < 0) <span class="label label-danger">{{$vp - $np}}</span>
|
||||
@else <span class="label label-warning">{{$vp - $np}}</span>
|
||||
@endif
|
||||
@if($stimme == 1)
|
||||
<span class="label label-success tooltip-enable" data-toggle="tooltip" title="Dafür gestimmt."><span class="glyphicon glyphicon-thumbs-up"></span></span>
|
||||
@elseif($stimme == 0)
|
||||
<span class="label label-danger tooltip-enable" data-toggle="tooltip" title="Dagegen gestimmt."><span class="glyphicon glyphicon-thumbs-down"></span></span>
|
||||
@endif
|
||||
</td>
|
||||
<td>{{ \Carbon\Carbon::parse($film->vorgeschlagen)->format('d.m.Y')}}</td>
|
||||
<td>{{ Film::find($film->id)->besitzer->name }}</td>
|
||||
|
Reference in New Issue
Block a user