Skip to content

Commit

Permalink
Save resources by targeting specific type
Browse files Browse the repository at this point in the history
  • Loading branch information
aerni committed May 29, 2024
1 parent 678066e commit e30692b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Sitemap/SitemapRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

namespace Aerni\AdvancedSeo\Sitemap;

use Illuminate\Support\Str;
use Illuminate\Support\Collection;
use Statamic\Facades\Collection as CollectionApi;
use Statamic\Facades\Taxonomy as TaxonomyApi;
use Aerni\AdvancedSeo\Contracts\Sitemap;
use Statamic\Facades\Taxonomy as TaxonomyApi;
use Statamic\Facades\Collection as CollectionApi;

class SitemapRepository
{
Expand Down Expand Up @@ -38,7 +39,9 @@ public function all(): Collection

public function find(string $id): ?Sitemap
{
return $this->all()->first(fn ($sitemap) => $id === $sitemap->id());
$method = Str::before($id, '::') . 'Sitemaps';

return $this->$method()->first(fn ($sitemap) => $id === $sitemap->id());
}

public function collectionSitemaps(): Collection
Expand Down

0 comments on commit e30692b

Please sign in to comment.