@@ -12,7 +12,7 @@ |
||
| 12 | 12 | parent::__construct($cmsObject, $properties); |
| 13 | 13 | |
| 14 | 14 | // Remove extra component from end |
| 15 | - if(ends_with($this->dirName, 'component')) { |
|
| 15 | + if (ends_with($this->dirName, 'component')) { |
|
| 16 | 16 | $this->dirName = substr($this->dirName, 0, -9); |
| 17 | 17 | } |
| 18 | 18 | } |
@@ -5,7 +5,8 @@ |
||
| 5 | 5 | use Cms\Classes\CodeBase; |
| 6 | 6 | use Cms\Classes\ComponentBase as OctoberComponentBase; |
| 7 | 7 | |
| 8 | -abstract class ComponentBase extends OctoberComponentBase { |
|
| 8 | +abstract class ComponentBase extends OctoberComponentBase |
|
| 9 | +{ |
|
| 9 | 10 | |
| 10 | 11 | public function __construct(CodeBase $cmsObject = null, $properties = []) |
| 11 | 12 | { |
@@ -74,8 +74,8 @@ |
||
| 74 | 74 | $showSlugFilter = $this->property('showSlugFilter'); |
| 75 | 75 | if (!empty($showSlugFilter)) { |
| 76 | 76 | $this->show = Show::query() |
| 77 | - ->where('slug', $showSlugFilter) |
|
| 78 | - ->firstOrFail(); |
|
| 77 | + ->where('slug', $showSlugFilter) |
|
| 78 | + ->firstOrFail(); |
|
| 79 | 79 | |
| 80 | 80 | $this->episode = $this->show->episodes() |
| 81 | 81 | ->getQuery() |
@@ -174,25 +174,25 @@ |
||
| 174 | 174 | public function setState() |
| 175 | 175 | { |
| 176 | 176 | $this->show = $show = Show::query() |
| 177 | - ->where('slug', $this->property('showSlug')) |
|
| 178 | - ->firstOrFail(); |
|
| 177 | + ->where('slug', $this->property('showSlug')) |
|
| 178 | + ->firstOrFail(); |
|
| 179 | 179 | $this->releaseType = $releaseType = ReleaseType::query() |
| 180 | - ->where('slug', $this->property('releaseTypeSlug')) |
|
| 181 | - ->firstOrFail(); |
|
| 180 | + ->where('slug', $this->property('releaseTypeSlug')) |
|
| 181 | + ->firstOrFail(); |
|
| 182 | 182 | $this->episodes = $this->show->episodes() |
| 183 | - ->with([ |
|
| 184 | - 'releases' => function (Relation $query) use ($releaseType) { |
|
| 185 | - /** @var Relation|Builder $query */ |
|
| 186 | - $query->where('release_type_id', $releaseType->id); |
|
| 187 | - } |
|
| 188 | - ]) |
|
| 189 | - ->where('published', true) |
|
| 190 | - ->whereHas('releases', function (Builder $query) use ($releaseType) { |
|
| 191 | - $query->where('release_type_id', $releaseType->id); |
|
| 192 | - }) |
|
| 193 | - ->orderBy('release', 'desc') |
|
| 194 | - ->take(intval($this->property('itemLimit'))) |
|
| 195 | - ->get(); |
|
| 183 | + ->with([ |
|
| 184 | + 'releases' => function (Relation $query) use ($releaseType) { |
|
| 185 | + /** @var Relation|Builder $query */ |
|
| 186 | + $query->where('release_type_id', $releaseType->id); |
|
| 187 | + } |
|
| 188 | + ]) |
|
| 189 | + ->where('published', true) |
|
| 190 | + ->whereHas('releases', function (Builder $query) use ($releaseType) { |
|
| 191 | + $query->where('release_type_id', $releaseType->id); |
|
| 192 | + }) |
|
| 193 | + ->orderBy('release', 'desc') |
|
| 194 | + ->take(intval($this->property('itemLimit'))) |
|
| 195 | + ->get(); |
|
| 196 | 196 | |
| 197 | 197 | $this->episodes->map(function (Episode $episode) use ($show) { |
| 198 | 198 | $episode->setRelation('show', $show); |
@@ -199,8 +199,8 @@ |
||
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | $query->with('image') |
| 202 | - ->where('published', true) |
|
| 203 | - ->orderBy('release', 'desc'); |
|
| 202 | + ->where('published', true) |
|
| 203 | + ->orderBy('release', 'desc'); |
|
| 204 | 204 | |
| 205 | 205 | if ($this->tag) { |
| 206 | 206 | $query->whereHas('tags', function (Builder $q) { |
@@ -211,7 +211,7 @@ |
||
| 211 | 211 | |
| 212 | 212 | // Generic rules |
| 213 | 213 | $query->with(['releases', 'releases.release_type', 'image', 'tags']) |
| 214 | - ->where('published', true); |
|
| 214 | + ->where('published', true); |
|
| 215 | 215 | |
| 216 | 216 | // If latest also order by |
| 217 | 217 | if($latest) { |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | // Episode slug filter |
| 195 | - if($this->property('episodeSlug')) { |
|
| 195 | + if ($this->property('episodeSlug')) { |
|
| 196 | 196 | // Load specific episode, unless show isn't set |
| 197 | 197 | $latest = $latest || false; |
| 198 | 198 | |
@@ -214,13 +214,13 @@ discard block |
||
| 214 | 214 | ->where('published', true); |
| 215 | 215 | |
| 216 | 216 | // If latest also order by |
| 217 | - if($latest) { |
|
| 217 | + if ($latest) { |
|
| 218 | 218 | $query->orderBy('release', 'desc'); |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | $episode = $query->firstOrFail(); |
| 222 | 222 | |
| 223 | - if($setShow) { |
|
| 223 | + if ($setShow) { |
|
| 224 | 224 | // Set show on episode |
| 225 | 225 | $episode->setRelation('show', $this->show); |
| 226 | 226 | } else { |