Film.php 543 B

1234567891011121314151617181920212223242526
  1. <?php
  2. class Film extends Eloquent {
  3. protected $table = "films";
  4. public function comments() {
  5. return $this->hasMany('Comment', 'film');
  6. }
  7. public function votes() {
  8. return $this->hasMany('Vote', 'film');
  9. }
  10. public function besitzer() {
  11. return $this->belongsTo('User', 'user');
  12. }
  13. public function scopeZuletztGesehen($query) {
  14. return $query->whereNotNull('gesehen')->orderBy('gesehen')->take(5);
  15. }
  16. public function scopeNeuesteVorschlage($query) {
  17. return $query->whereNull('gesehen')->orderBy('updated_at')->take(5);
  18. }
  19. }