+Bewertungen, Meistgewünschter Film, Sortierung nach Votes

This commit is contained in:
2013-09-27 04:06:12 +02:00
parent 521ecc46c1
commit fb74d68046
11 changed files with 264 additions and 20 deletions

View File

@@ -52,8 +52,17 @@
@endforeach
</dd>
<dt>Bewertung</dt>
<dd>{{ $tfilm['vote_average']}} von 10
</dd>
<dd>{{ $tfilm['vote_average']}} von 10 </dd>
@if(!is_null($film->gesehen) && Comment::where('film', $film->id)->where('bewertung', '>', 0)->count() > 0)
<dt>Eigene Bewertung</dt>
<dd>
<?php
$count = Comment::where('film', $film->id)->where('bewertung', '>', 0)->count();
$avg = Comment::where('film', $film->id)->where('bewertung', '>', 0)->sum('bewertung') / $count;
?>
<div class="label label-{{$labels[round($avg)]}}">{{$avg}}</div>
</dd>
@endif
@for($i = 0; $i < 3 && $i < count($cast['crew']); $i++)
<dt>{{$cast['crew'][$i]['job']}}</dt>
<dd>{{$cast['crew'][$i]['name']}}</dd>
@@ -132,6 +141,17 @@
<div class="media-body">
<h4 class="media-heading">Neuer Kommentar</h4>
{{Form::open(array('route' => 'comment'))}}
@if(!is_null(Auth::user()) && !is_null($film->gesehen) && Comment::where('user', Auth::user()->id)->where('film', $film->id)->where('bewertung', '>', 0)->count() < 1 )
<p><div class="pull-left" style="margin-right: 5px">Bewerten:</div>
<div class="btn-group btn-group-xs" data-toggle="buttons">
@for($i = 1; $i < 11; $i++)
<label class="btn btn-{{ $labels[$i] }}">
<input type="radio" name="rate" id="rate{{ $i }}" value="{{ $i }}"> {{ $i }}
</label>
@endfor
</div>
</p>
@endif
<input type="hidden" name="user" value="{{Auth::user()->id}}">
<input type="hidden" name="film" value="{{$film->id}}">
<div class="form-group"><textarea class="form-control" rows="1" name="text"></textarea></div>
@@ -155,11 +175,25 @@
</small></h5>
@if(!is_null(Auth::user()) && Auth::user()->id === $comment->autor->id)
<div class="collapse in" data-parent="#comment{{$comment->id}}" id="comment{{$comment->id}}comment">
@if($comment->bewertung > 0)
<div class="pull-left label label-{{ $labels[$comment->bewertung] }}" style="margin-right: 5px;">{{$comment->bewertung}}</div>
@endif
<p>{{$comment->text}}</p>
<button type="button" class="btn btn-xs" onclick="toggleComment('#comment{{$comment->id}}')">Bearbeiten</button>
</div>
<div class="collapse" id="comment{{$comment->id}}edit">
{{Form::open(array('route' => 'modcomment'))}}
@if($comment->bewertung > 0)
<p><div class="pull-left" style="margin-right: 5px">Bewerten:</div>
<div class="btn-group btn-group-xs" data-toggle="buttons">
@for($i = 1; $i < 11; $i++)
<label class="btn btn-{{ $labels[$i] }}">
<input type="radio" name="rate" id="rate{{ $i }}" value="{{ $i }}"> {{ $i }}
</label>
@endfor
</div>
</p>
@endif
<input type="hidden" name="id" value="{{$comment->id}}">
<div class="form-group"><textarea class="form-control" rows="1" name="text">{{$comment->text}}</textarea></div>
<div class="form-group">
@@ -169,6 +203,9 @@
{{Form::close()}}
</div>
@else
@if($comment->bewertung > 0)
<div class="pull-left label label-{{ $labels[$comment->bewertung] }}" style="margin-right: 5px;">{{$comment->bewertung}}</div>
@endif
<p>{{$comment->text}}</p>
@endif
</div>

View File

@@ -36,6 +36,7 @@
<li>{{ HTML::link('settings', 'Passwort &amp; Email &auml;ndern')}}</li>
@if(Auth::user()->admin)
<li>{{ HTML::link('users', 'Benutzerverwaltung')}}</li>
<li>{{ HTML::link('news', 'News erstellen')}}</li>
@endif
<li class="divider"></li>
<li>{{ HTML::link('logout', "Logout")}}

View File

@@ -1,10 +1,39 @@
@extends('hello');
@section('content')
<div class="jumbotron">
<div class="container">
<h1>Willkommen zu Dumbo</h1>
<p>Dumbo ist der Arbeitstitel für eine kleine Software, die helfen soll Filme für den Filmabend auszuwählen. Um den Programmieraufwand klein zu halten, baut Dumbo auf <a href="http://laravel.com">Laravel 4</a> und <a href="http://getbootstrap.com">Twitter Bootstrap 3</a> auf. Die Filmdetails werden von <a href="http://themoviedb.org">themoviedb.org</a> bezogen.</p>
<div class="row">
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">Meistgew&uuml;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>&nbsp;{{$topfilm->upvotes}}
<span class="glyphicon glyphicon-thumbs-down"></span>&nbsp;{{$topfilm->downvotes}}</p>
</div>
<div class="list-group">
{{ link_to_route('film', "Filmdetails", array($topfilm->id), array('class' => 'list-group-item'))}}
</div>
</div>
</div>
<div class="col-md-6">
<div class="panel-group" id="accordion">
@foreach ($news as $new)
<div class="panel panel-warning">
<div class="panel-heading">
<h4 class="panel-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#news{{$new->id}}">{{$new->headline}}</a>
<small>{{$new->ersteller->name}} - {{\Carbon\Carbon::parse($new->updated_at)->format('d.m.Y')}}</small>
</h5>
</div>
<div id="news{{$new->id}}" class="panel-collapse collapse">
<div class="panel-body">{{nl2br(htmlentities($new->body))}}</div>
</div>
</div>
@endforeach
</div>
</div>
</div>

39
app/views/news.blade.php Normal file
View File

@@ -0,0 +1,39 @@
@extends('hello')
@section('content')
<div class="container" style="margin-top: 40px;">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading"><h2 class="panel-title">News erstellen</h2></div>
<div class="panel-body">
{{Form::open(array('url' => 'news'))}}
@if(count($errors->all()) > 0)
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert">&times;</button>
Es müssen beide Felder ausgefüllt werden!
</div>
@endif
<div class="input-group form-group <?php if($errors->has('headline')) echo "has-error" ?>">
<span class="input-group-addon">
<span class="glyphicon glyphicon-paperclip"></span>
</span>
<input type="text" class="form-control" name="headline" placeholder="&Uuml;berschrift" <?php if(!is_null(Input::get('headline'))) echo "value='" . Input::get('headline') . "'"; ?>>
</div>
<div class="form-group <?php if($errors->has('email')) echo "has-error" ?>">
<textarea class="form-control" name="body" placeholder="Nachricht"><?php if(!is_null(Input::get('body'))) echo Input::get('body') . "'"; ?></textarea>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">Absenden</button>
</div>
{{ Form::close() }}
</div>
</div>
</div>
</div>
</div>
@stop
@section('title')
News erstellen ~
@stop

View File

@@ -17,20 +17,20 @@
<td>{{ HTML::link('film/' . $film->id, $film->name) }}</td>
<td>
<?php
$vp = $film->votes()->where('stimme', true)->count();
$np = $film->votes()->where('stimme', false)->count();
$vp = $film->upvotes;
$np = $film->downvotes;
?>
<div class="progress tooltip-enable" data-toggle="tooltip" title="{{ $vp }}/{{ $np }}">
<div class="progress-bar progress-bar-success" style="width: <?php if(($vp + $np) > 0) echo ($vp / ($vp + $np) * 100); else echo 0; ?>%">
<span class="sr-only">{{$vp}} von {{$vp + $np}} (daf&uuml;r)</span>
</div>
<div class="progress-bar progress-bar-danger" style="width: <?php if(($vp + $np) > 0) echo ($vp / ($vp + $np) * 100); else echo 0; ?>%">
<div class="progress-bar progress-bar-danger" style="width: <?php if(($vp + $np) > 0) echo ($np / ($vp + $np) * 100); else echo 0; ?>%">
<span class="sr-only">{{$np}} von {{$vp + $np}} (dagegen)</span>
</div>
</div>
</td>
<td>{{ \Carbon\Carbon::parse($film->vorgeschlagen)->format('d.m.Y')}}</td>
<td>{{ $film->besitzer->name }}</td>
<td>{{ Film::find($film->id)->besitzer->name }}</td>
</tr>
@endforeach
</table>