Bugfix Order
This commit is contained in:
@@ -28,12 +28,13 @@ class Film extends Eloquent {
|
||||
return $query
|
||||
->addSelect(DB::raw('film_films.*, COUNT(case when film_votes.stimme IS TRUE then 1 end) as upvotes'))
|
||||
->leftJoin('votes', 'votes.film', '=', 'films.id')
|
||||
->leftJoin('users', 'users.id', '=', 'votes.user')
|
||||
->whereNull('gesehen')
|
||||
->where('films.id', "!=", is_object($nextfilm) ? $nextfilm->id : 0)
|
||||
->where('users.settings', 'NOT LIKE', '%disabled":true%')
|
||||
->groupBy('films.id')
|
||||
->orderBy('upvotes', 'DESC')
|
||||
->orderBy('vorgeschlagen', 'ASC')
|
||||
->take(5);
|
||||
->orderBy('vorgeschlagen', 'ASC');
|
||||
}
|
||||
|
||||
public function getVotes() {
|
||||
|
@@ -61,7 +61,7 @@ class User extends Eloquent implements UserInterface, RemindableInterface {
|
||||
|
||||
public function getSetting($key, $false = false) {
|
||||
$settings = json_decode($this->settings);
|
||||
if(!is_null($settings))
|
||||
if(!is_null($settings) && property_exists($settings, $key))
|
||||
return $settings->$key;
|
||||
else
|
||||
return $false;
|
||||
|
@@ -16,7 +16,9 @@ Route::get('/', function()
|
||||
{
|
||||
$gesehen = Film::zuletztGesehen()->get();
|
||||
$vorgeschlagen = Film::neuesteVorschlage()->get();
|
||||
$mg = Film::meistgewunschteVorschlage()->get();
|
||||
$mg = Film::meistgewunschteVorschlage()->take(5)->get();
|
||||
//$x = DB::getQueryLog();
|
||||
//dd(end($x));
|
||||
|
||||
$news = News::aktuell()->get();
|
||||
$nextfilm = Dumbo::find(1)->film;
|
||||
@@ -160,15 +162,7 @@ Route::get('logout', array('as' => 'logout', function() {
|
||||
|
||||
Route::get('beliebt', function() {
|
||||
|
||||
$filme = DB::table(DB::raw('film_films'))
|
||||
->select(DB::raw('film_films.*, COUNT(case when film_votes.stimme IS TRUE then 1 end) as upvotes,
|
||||
COUNT(case when film_votes.stimme IS FALSE then 1 end) as downvotes,
|
||||
COUNT(case when film_votes.stimme IS TRUE then 1 end) as vcount'))
|
||||
->leftJoin('votes', 'votes.film', '=', 'films.id')
|
||||
->whereNull('films.gesehen')
|
||||
->groupBy('id')
|
||||
->orderBy('vcount', 'DESC')->orderBy('vorgeschlagen', 'ASC')
|
||||
->paginate(25);
|
||||
$filme = Film::meistgewunschteVorschlage()->paginate(25);
|
||||
|
||||
return View::make('suggest')
|
||||
->with('filme', $filme)
|
||||
@@ -377,6 +371,7 @@ Route::get('users', array('before' => 'auth', function() {
|
||||
|
||||
Route::get('users/{operation}/{id}', array('before' => 'auth', function($operation, $id) {
|
||||
if(!Auth::user()->admin) App::abort(401, 'Diese Seite ist nicht für Dich.');
|
||||
/** @var User $u */
|
||||
$u = User::findOrFail($id);
|
||||
switch($operation) {
|
||||
case 'mkadm':
|
||||
@@ -393,6 +388,16 @@ Route::get('users/{operation}/{id}', array('before' => 'auth', function($operati
|
||||
$msg = $u->name . " wurde gelöscht.";
|
||||
$u->delete();
|
||||
break;
|
||||
case 'inact':
|
||||
$msg = $u->name. " ist inaktiv.";
|
||||
$u->setSetting("disabled", true);
|
||||
$u->save();
|
||||
break;
|
||||
case 'act':
|
||||
$msg = $u->name. " ist aktiv.";
|
||||
$u->setSetting("disabled", false);
|
||||
$u->save();
|
||||
break;
|
||||
}
|
||||
|
||||
return Redirect::to('users')->with('message', $msg);
|
||||
@@ -500,16 +505,16 @@ Route::get('stats', function() {
|
||||
array(
|
||||
'name' => 'Bewertet am besten',
|
||||
'entr' => array('', ''),
|
||||
'vals' => Comment::addselect(DB::raw('film_comments.*, ROUND(AVG(`bewertung`),1) as count'))
|
||||
->where('bewertung', '!=', 0)->groupBy('user')->orderBy('count', 'DESC')->raw('ORDER BY COUNT(*) DESC')->take(3)->get(),
|
||||
'vals' => Comment::addselect(DB::raw('film_comments.*, ROUND(AVG(`bewertung`),1) as count, COUNT(*) as no'))
|
||||
->where('bewertung', '!=', 0)->groupBy('user')->orderBy('count', 'DESC')->orderBy('no', 'DESC')->take(3)->get(),
|
||||
'prop' => 'autor',
|
||||
'type' => 'User'
|
||||
),
|
||||
array(
|
||||
'name' => 'Bewertet am schlechtesten',
|
||||
'entr' => array('', ''),
|
||||
'vals' => Comment::addselect(DB::raw('film_comments.*, ROUND(AVG(`bewertung`),1) as count'))
|
||||
->where('bewertung', '!=', 0)->groupBy('user')->orderBy('count', 'ASC')->raw('ORDER BY COUNT(*) ASC')->take(3)->get(),
|
||||
'vals' => Comment::addselect(DB::raw('film_comments.*, ROUND(AVG(`bewertung`),1) as count, COUNT(*) as no'))
|
||||
->where('bewertung', '!=', 0)->groupBy('user')->orderBy('count', 'ASC')->orderBy('no', 'ASC')->take(3)->get(),
|
||||
'prop' => 'autor',
|
||||
'type' => 'User'
|
||||
),
|
||||
|
@@ -3,17 +3,23 @@
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
@if(is_object($nextfilm))
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">Nächster Film</div>
|
||||
<div class="panel-body">
|
||||
<img src="{{$images["next"]}}" class="pull-left thumbnail" style="max-height: 100px; margin-right: 15px;">
|
||||
<h4>{{is_object($nextfilm) ? $nextfilm->name . " <small><i>(" . $nextfilm->besitzer->name . ")</i></small>" : "Steht nicht fest"}}</h4>
|
||||
@if(is_object($nextfilm)) {{ link_to_route('film', "Filmdetails", array($nextfilm->id), array('class' => 'btn btn-info btn-xs'))}}
|
||||
@endif
|
||||
@if(is_object($nextfilm) && !is_null(Auth::user()) && Auth::user()->admin) <a href='{{ url('mark-read/' . $nextfilm->id) }}' class='btn btn-success btn-xs'>Gesehen</a>
|
||||
<h4>
|
||||
{{ $nextfilm->name }}
|
||||
<small><span class="badge">
|
||||
<img class="img-circle" src="{{ $nextfilm->besitzer->getAvatar() }}" width="20"> {{$nextfilm->besitzer->name}}
|
||||
</span></small>
|
||||
</h4>
|
||||
{{ link_to_route('film', "Filmdetails", array($nextfilm->id), array('class' => 'btn btn-info btn-xs'))}}
|
||||
@if(!is_null(Auth::user()) && Auth::user()->admin) <a href='{{ url('mark-read/' . $nextfilm->id) }}' class='btn btn-success btn-xs'>Gesehen</a>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">Meistgewünschter Film</div>
|
||||
@@ -102,11 +108,6 @@
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<div class="jumbotron">
|
||||
<h1>Dumbo</h1>
|
||||
<p>Suchst du noch oder guckst du schon?</p>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Letzte Kommentare</div>
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
<div class="col-md-2">
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li class="active"><a href="#avatar" data-toggle="pill">Avatar</a></li>
|
||||
<li><a href="#password" data-toggle="pill">Password</a></li>
|
||||
<li><a href="#password" data-toggle="pill">Passwort</a></li>
|
||||
<li><a href="#email" data-toggle="pill">E-Mail</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@@ -25,11 +25,16 @@
|
||||
@if($user->admin)
|
||||
@if($user->name != "Daniel")
|
||||
<button class="btn btn-primary btn-xs" type="button">Admin</button>
|
||||
<a class="btn btn-warning btn-xs" type="button" href="{{ url('users/rmadm/' . $user->id) }}">Rechte entziehen</a>
|
||||
<a class="btn btn-default btn-xs" type="button" href="{{ url('users/rmadm/' . $user->id) }}">Rechte entziehen</a>
|
||||
@else
|
||||
—
|
||||
@endif
|
||||
@else
|
||||
@if(!$user->getSetting("disabled"))
|
||||
<a class="btn btn-default btn-xs" type="button" href="{{ url("users/inact/" . $user->id) }}">Deaktivieren</a>
|
||||
@else
|
||||
<a class="btn btn-default btn-xs" type="button" href="{{ url("users/act/" . $user->id) }}">Aktivieren</a>
|
||||
@endif
|
||||
<a class="btn btn-default btn-xs" type="button" href="{{ url('users/mkadm/' . $user->id) }}">Zum Admin machen</a>
|
||||
<a class="btn btn-danger btn-xs" type="button" href="{{ url('users/rmusr/' . $user->id) }}">Löschen</a>
|
||||
@endif
|
||||
|
Reference in New Issue
Block a user