Added abgelehnt feature, fixed counting up/downvotes on landing page and movies by date page

This commit is contained in:
Sebastian Uharek
2021-02-23 00:55:56 +01:00
parent c58fe40fbe
commit b03397d1dc
7 changed files with 184 additions and 11 deletions

View File

@@ -16,11 +16,15 @@ class Film extends Eloquent {
}
public function scopeZuletztGesehen($query) {
return $query->whereNotNull('gesehen')->orderBy('gesehen', 'DESC')->take(5);
return $query->whereNull('abgelehnt')->whereNotNull('gesehen')->orderBy('gesehen', 'DESC')->take(5);
}
public function scopeZuletztAbgelehnt($query) {
return $query->whereNull('gesehen')->whereNotNull('abgelehnt')->orderBy('abgelehnt', 'DESC')->take(5);
}
public function scopeNeuesteVorschlage($query) {
return $query->whereNull('gesehen')->orderBy('updated_at', 'DESC')->take(5);
return $query->whereNull('gesehen')->whereNull('abgelehnt')->orderBy('updated_at', 'DESC')->take(5);
}
public function scopeMeistgewunschteVorschlage($query) {
@@ -30,6 +34,7 @@ class Film extends Eloquent {
->leftJoin('votes', 'votes.film', '=', 'films.id')
->leftJoin('users', 'users.id', '=', 'votes.user')
->whereNull('gesehen')
->whereNull('abgelehnt')
->where('films.id', "!=", is_object($nextfilm) ? $nextfilm->id : 0)
->where('users.settings', 'NOT LIKE', '%disabled":true%')
->groupBy('films.id')
@@ -38,11 +43,18 @@ class Film extends Eloquent {
}
public function getVotes() {
return Vote::where('film', '=', $this->id)->count();
return Vote::where('film', '=', $this->id)
->where('users.settings', 'NOT LIKE', '%disabled":true%')
->leftJoin('users', 'users.id', '=', 'votes.user')
->count();
}
public function getUpvotes() {
return Vote::where('film', '=', $this->id)->whereRaw('stimme IS TRUE')->count();
return Vote::where('film', '=', $this->id)
->whereRaw('stimme IS TRUE')
->where('users.settings', 'NOT LIKE', '%disabled":true%')
->leftJoin('users', 'users.id', '=', 'votes.user')
->count();
}
public function getBewertung() {