Skip to content

Commit

Permalink
Merge pull request #209 from SlovakNationalGallery/KOMARCH-287-condit…
Browse files Browse the repository at this point in the history
…ionally-searchable-posts

make only published posts searchable in scout
  • Loading branch information
igor-kamil committed Feb 8, 2024
2 parents 1af18c7 + 310a6eb commit f871887
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/Models/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,8 @@ public function registerMediaCollections(): void
->withResponsiveImages();
}

public function shouldBeSearchable(): bool
{
return $this->is_published;
}
}
2 changes: 1 addition & 1 deletion tests/Feature/PostTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class PostTest extends TestCase

public function testDetailUrl()
{
$post = \App\Models\Post::factory()->create();
$post = \App\Models\Post::factory()->published()->create();
$url = route('posts.show', [$post->slug]);
$response = $this->get($url);
$response->assertStatus(200);
Expand Down

0 comments on commit f871887

Please sign in to comment.