Added abgelehnt feature, fixed counting up/downvotes on landing page and movies by date page
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
Route::get('/', function()
|
||||
{
|
||||
$gesehen = Film::zuletztGesehen()->get();
|
||||
$abgelehnt = Film::zuletztAbgelehnt()->get();
|
||||
$vorgeschlagen = Film::neuesteVorschlage()->get();
|
||||
$mg = Film::meistgewunschteVorschlage()->take(5)->get();
|
||||
//$x = DB::getQueryLog();
|
||||
@@ -24,7 +25,7 @@ Route::get('/', function()
|
||||
$nextfilm = Dumbo::find(1)->film;
|
||||
|
||||
$tmdb = new TMDb(Config::get('constants.tvdb.apikey'), 'de', TRUE, TMDb::API_SCHEME_SSL);
|
||||
foreach(array("top" => $mg[0], "neu" => $vorgeschlagen[0], "alt" => $gesehen[0]) as $key => $val) {
|
||||
foreach(array("top" => $mg[0], "neu" => $vorgeschlagen[0], "alt" => $gesehen[0], "declined" => $abgelehnt[0]) as $key => $val) {
|
||||
$tmovie = $tmdb->getMovie($val->tvdbid);
|
||||
$images[$key] = $tmdb->getImageUrl($tmovie['poster_path'], TMDb::IMAGE_POSTER, 'w342');
|
||||
}
|
||||
@@ -42,6 +43,7 @@ Route::get('/', function()
|
||||
|
||||
return View::make('index')
|
||||
->with('gesehen', $gesehen)
|
||||
->with('abgelehnt', $abgelehnt)
|
||||
->with('vorgeschlagen', $vorgeschlagen)
|
||||
->with('meistgw', $mg)
|
||||
->with('images', $images)
|
||||
@@ -177,7 +179,10 @@ Route::get('vorgeschlagen', function() {
|
||||
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')
|
||||
->leftJoin('users', 'users.id', '=', 'votes.user')
|
||||
->whereNull('films.gesehen')
|
||||
->whereNull('films.abgelehnt')
|
||||
->where('users.settings', 'NOT LIKE', '%disabled":true%')
|
||||
->groupBy('id')
|
||||
->orderBy('vorgeschlagen', 'DESC')
|
||||
->paginate(25);
|
||||
@@ -188,6 +193,16 @@ Route::get('vorgeschlagen', function() {
|
||||
|
||||
});
|
||||
|
||||
Route::get('abgelehnt/{field?}/{order?}', function($field = "abgelehnt", $order = "desc") {
|
||||
$filme = Film::whereNotNull('abgelehnt')->orderBy($field, $order)->paginate(25);
|
||||
$labels = array("", "danger", "danger", "warning", "warning", "info", "info", "primary", "primary", "success", "success");
|
||||
|
||||
return View::make('abgelehnt')
|
||||
->with('labels', $labels)
|
||||
->with('filme', $filme);
|
||||
|
||||
})->where(array('field' => '[a-z]+', 'order' => 'asc|desc'));
|
||||
|
||||
Route::get('gesehen/{field?}/{order?}', function($field = "gesehen", $order = "desc") {
|
||||
$filme = Film::whereNotNull('gesehen')->orderBy($field, $order)->paginate(25);
|
||||
$labels = array("", "danger", "danger", "warning", "warning", "info", "info", "primary", "primary", "success", "success");
|
||||
@@ -212,7 +227,7 @@ Route::post('neu', array('before' => 'auth', function() {
|
||||
}));
|
||||
|
||||
Route::get('vorschlag/{id}', array('before' => 'auth', function($id) {
|
||||
$ef = Film::where('tvdbid', '=', $id)->whereNull('gesehen')->first();
|
||||
$ef = Film::where('tvdbid', '=', $id)->whereNull('gesehen')->whereNull('abgelehnt')->first();
|
||||
if(is_null($ef)) {
|
||||
$tmdb = new TMDb('b187f8d9c5e72b1faecb741d5d04239a', 'de', TRUE);
|
||||
$f = $tmdb->getMovie($id);
|
||||
@@ -225,11 +240,27 @@ Route::get('vorschlag/{id}', array('before' => 'auth', function($id) {
|
||||
Session::put('message', 'Film hinzugefügt.');
|
||||
return Redirect::to('film/' . $film->id);
|
||||
} else {
|
||||
Session::put('message', 'Film bereits vorgeschlagen von ' . $ef->besitzer->name . '.');
|
||||
if(is_null($ef->abgelehnt)) {
|
||||
Session::put('message', 'Film bereits vorgeschlagen von ' . $ef->besitzer->name . '.');
|
||||
} else {
|
||||
Session::put('message', 'Film bereits abgelehmt.');
|
||||
}
|
||||
return Redirect::to('film/' . $ef->id);
|
||||
}
|
||||
}));
|
||||
|
||||
Route::get('mark-declined/{id}', array('before' => 'auth', function($id) {
|
||||
$film = Film::findOrFail($id);
|
||||
$film->abgelehnt = \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('mark-read/{id}', array('before' => 'auth', function($id) {
|
||||
$film = Film::findOrFail($id);
|
||||
$film->gesehen = \Carbon\Carbon::today();
|
||||
@@ -485,6 +516,14 @@ Route::get('stats', function() {
|
||||
'prop' => 'besitzer',
|
||||
'type' => 'User'
|
||||
),
|
||||
array(
|
||||
'name' => 'Meiste abgelehnte Vorschläge',
|
||||
'entr' => array('Vorschlag', 'Vorschläge'),
|
||||
'vals' => Film::addSelect(DB::raw("film_films.*, COUNT(`id`) as count"))
|
||||
->whereNotNull('abgelehnt')->groupBy('user')->orderBy('count', 'DESC')->take(3)->get(),
|
||||
'prop' => 'besitzer',
|
||||
'type' => 'User'
|
||||
),
|
||||
|
||||
array(
|
||||
'name' => 'Meiste Kommentare',
|
||||
@@ -563,4 +602,4 @@ Route::get('stats', function() {
|
||||
];
|
||||
|
||||
return View::make('stats')->with('stats', $stats);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user