@@ 130-136 (lines=7) @@ | ||
127 | * @param boolean $ofShow If true returns the next episode of the same show |
|
128 | * @return Episode The next episode |
|
129 | */ |
|
130 | public function next($ofShow = false) { |
|
131 | $query = self::query(); |
|
132 | if ($ofShow) { |
|
133 | $query = $query->where('show_id',$this->show_id); |
|
134 | } |
|
135 | return $query->where('published',true)->where('release','>',$this->release)->orderBy('release','asc')->take(1)->get()->first(); |
|
136 | } |
|
137 | /** |
|
138 | * Returns the previous episode |
|
139 | * @param boolean $ofShow If true returns the previous episode of the same show |
|
@@ 142-148 (lines=7) @@ | ||
139 | * @param boolean $ofShow If true returns the previous episode of the same show |
|
140 | * @return Episode The previous episode |
|
141 | */ |
|
142 | public function previous($ofShow = false) { |
|
143 | $query = self::query(); |
|
144 | if ($ofShow) { |
|
145 | $query = $query->where('show_id',$this->show_id); |
|
146 | } |
|
147 | return $query->where('published',true)->where('release','<',$this->release)->orderBy('release','desc')->take(1)->get()->first(); |
|
148 | } |
|
149 | ||
150 | /** |
|
151 | * Runs before an episode is deleted to remove all the releases that depend on it |