Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Entries/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -791,11 +791,11 @@ public function status()
return 'published';
}

if ($collection->futureDateBehavior() === 'private' && $this->date()->isFuture()) {
if (($collection->futureDateBehavior() === 'private' || $collection->futureDateBehavior() === 'unlisted') && $this->date()->isFuture()) {
return 'scheduled';
}

if ($collection->pastDateBehavior() === 'private' && $this->date()->isPast()) {
if (($collection->pastDateBehavior() === 'private' || $collection->pastDateBehavior() === 'unlisted') && $this->date()->isPast()) {
return 'expired';
}

Expand Down
4 changes: 2 additions & 2 deletions src/Stache/Query/QueriesEntryStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private function addCollectionStatusLogicToQuery($query, $status, $collection):
return;
}

if ($collection->futureDateBehavior() === 'private') {
if ($collection->futureDateBehavior() === 'private' || $collection->futureDateBehavior() === 'unlisted') {
$status === 'scheduled'
? $query->where('date', '>', now())
: $query->where('date', '<', now());
Expand All @@ -55,7 +55,7 @@ private function addCollectionStatusLogicToQuery($query, $status, $collection):
}
}

if ($collection->pastDateBehavior() === 'private') {
if ($collection->pastDateBehavior() === 'private' || $collection->pastDateBehavior() === 'unlisted') {
$status === 'expired'
? $query->where('date', '<', now())
: $query->where('date', '>', now());
Expand Down
8 changes: 4 additions & 4 deletions tests/Tags/Collection/EntriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,10 @@ public function it_filters_by_future_and_past()

// Only future
$this->collection->dated(true)->futureDateBehavior('public')->pastDateBehavior('unlisted')->save();
$this->assertCount(3, $this->getEntries());

$this->assertCount(0, $this->getEntries(['show_future' => false]));
$this->assertCount(3, $this->getEntries(['show_future' => true]));
$this->assertCount(8, $this->getEntries(['show_past' => true]));
$this->assertCount(3, $this->getEntries(['show_past' => true]));
$this->assertCount(3, $this->getEntries(['show_past' => false]));
$this->assertCount(3, $this->getEntries(['show_past' => false, 'show_future' => true]));

Expand All @@ -300,10 +300,10 @@ public function it_filters_by_future_and_past()
$this->collection->dated(true)->futureDateBehavior('unlisted')->pastDateBehavior('public')->save();
$this->assertCount(4, $this->getEntries());
$this->assertCount(4, $this->getEntries(['show_future' => false]));
$this->assertCount(8, $this->getEntries(['show_future' => true]));
$this->assertCount(4, $this->getEntries(['show_future' => true]));
$this->assertCount(4, $this->getEntries(['show_past' => true]));
$this->assertCount(0, $this->getEntries(['show_past' => false]));
$this->assertCount(3, $this->getEntries(['show_past' => false, 'show_future' => true]));
$this->assertCount(0, $this->getEntries(['show_past' => false, 'show_future' => true]));

$this->collection->dated(true)->futureDateBehavior('private')->pastDateBehavior('public')->save();
$this->assertCount(4, $this->getEntries());
Expand Down