| @@ 202-225 (lines=24) @@ | ||
| 199 | * |
|
| 200 | * @return void |
|
| 201 | */ |
|
| 202 | private function postRelation(Builder $query, array $options) |
|
| 203 | { |
|
| 204 | if (!empty($options['fetchPosts'])) { |
|
| 205 | $query->with( |
|
| 206 | [ |
|
| 207 | 'posts' => static function (MorphToMany $query) use ($options) { |
|
| 208 | $query->isPublished(); |
|
| 209 | ||
| 210 | self::handleExceptions($query->getQuery(), $options); |
|
| 211 | } |
|
| 212 | ] |
|
| 213 | ); |
|
| 214 | } |
|
| 215 | ||
| 216 | $query->withCount( |
|
| 217 | [ |
|
| 218 | 'posts' => static function ($query) use ($options) { |
|
| 219 | $query->isPublished(); |
|
| 220 | ||
| 221 | self::handleExceptions($query, $options); |
|
| 222 | } |
|
| 223 | ] |
|
| 224 | ); |
|
| 225 | } |
|
| 226 | ||
| 227 | /** |
|
| 228 | * @param Builder $query |
|
| @@ 233-254 (lines=22) @@ | ||
| 230 | * |
|
| 231 | * @return void |
|
| 232 | */ |
|
| 233 | private function seriesRelation(Builder $query, array $options) |
|
| 234 | { |
|
| 235 | $query->withCount('series'); |
|
| 236 | ||
| 237 | if (!empty($options['fetchSeriesPostCount'])) { |
|
| 238 | $query->with( |
|
| 239 | [ |
|
| 240 | 'series' => static function (MorphToMany $query) use ($options) { |
|
| 241 | $query->withCount( |
|
| 242 | [ |
|
| 243 | 'posts' => static function ($query) use ($options) { |
|
| 244 | $query->isPublished(); |
|
| 245 | ||
| 246 | self::handleExceptions($query, $options); |
|
| 247 | } |
|
| 248 | ] |
|
| 249 | ); |
|
| 250 | } |
|
| 251 | ] |
|
| 252 | ); |
|
| 253 | } |
|
| 254 | } |
|
| 255 | } |
|
| 256 | ||