| @@ 387-411 (lines=25) @@ | ||
| 384 | * |
|
| 385 | * @return \Illuminate\Support\Collection |
|
| 386 | */ |
|
| 387 | protected function getExistingSlugs(string $slug, string $attribute, array $config): Collection |
|
| 388 | { |
|
| 389 | $includeTrashed = $config['includeTrashed']; |
|
| 390 | ||
| 391 | $query = $this->model->newQuery() |
|
| 392 | ->findSimilarSlugs($attribute, $config, $slug); |
|
| 393 | ||
| 394 | // use the model scope to find similar slugs |
|
| 395 | if (method_exists($this->model, 'scopeWithUniqueSlugConstraints')) { |
|
| 396 | $query->withUniqueSlugConstraints($this->model, $attribute, $config, $slug); |
|
| 397 | } |
|
| 398 | ||
| 399 | // include trashed models if required |
|
| 400 | if ($includeTrashed && $this->usesSoftDeleting()) { |
|
| 401 | $query->withTrashed(); |
|
| 402 | } |
|
| 403 | ||
| 404 | // get the list of all matching slugs |
|
| 405 | $results = $query->select([$attribute, $this->model->getQualifiedKeyName()]) |
|
| 406 | ->get() |
|
| 407 | ->toBase(); |
|
| 408 | ||
| 409 | // key the results and return |
|
| 410 | return $results->pluck($attribute, $this->model->getKeyName()); |
|
| 411 | } |
|
| 412 | ||
| 413 | /** |
|
| 414 | * Does this model use softDeleting? |
|
| @@ 373-397 (lines=25) @@ | ||
| 370 | * |
|
| 371 | * @return \Illuminate\Support\Collection |
|
| 372 | */ |
|
| 373 | protected function getExistingSlugs(string $slug, string $attribute, array $config): Collection |
|
| 374 | { |
|
| 375 | $includeTrashed = $config['includeTrashed']; |
|
| 376 | ||
| 377 | $query = $this->model->newQuery() |
|
| 378 | ->findSimilarSlugs($attribute, $config, $slug); |
|
| 379 | ||
| 380 | // use the model scope to find similar slugs |
|
| 381 | if (method_exists($this->model, 'scopeWithUniqueSlugConstraints')) { |
|
| 382 | $query->withUniqueSlugConstraints($this->model, $attribute, $config, $slug); |
|
| 383 | } |
|
| 384 | ||
| 385 | // include trashed models if required |
|
| 386 | if ($includeTrashed && $this->usesSoftDeleting()) { |
|
| 387 | $query->withTrashed(); |
|
| 388 | } |
|
| 389 | ||
| 390 | // get the list of all matching slugs |
|
| 391 | $results = $query->select([$attribute, $this->model->getQualifiedKeyName()]) |
|
| 392 | ->get() |
|
| 393 | ->toBase(); |
|
| 394 | ||
| 395 | // key the results and return |
|
| 396 | return $results->pluck($attribute, $this->model->getKeyName()); |
|
| 397 | } |
|
| 398 | ||
| 399 | /** |
|
| 400 | * Does this model use softDeleting? |
|