Skip to content

Commit

Permalink
Move condition into Revisable@store
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean committed Jan 18, 2024
1 parent ca6ad40 commit c74623d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ public function __invoke(Request $request, $collection, $entry)

$localized = $entry->makeLocalization($site = $request->site);

if ($entry->revisionsEnabled()) {
$localized->store(['user' => User::fromUser($request->user())]);
} else {
$localized->published(false)->updateLastModified($request->user())->save();
}
$localized->store(['user' => User::fromUser($request->user())]);

return [
'handle' => $site,
Expand Down
16 changes: 10 additions & 6 deletions src/Revisions/Revisable.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,20 @@ public function unpublishWorkingCopy($options = [])

public function store($options = [])
{
$this
$return = $this
->published(false)
->updateLastModified($user = $options['user'] ?? false)
->save();

return $this
->makeRevision()
->user($user)
->message($options['message'] ?? false)
->save();
if ($this->revisionsEnabled()) {
$return = $this
->makeRevision()
->user($user)
->message($options['message'] ?? false)
->save();
}

return $return;
}

public function createRevision($options = [])
Expand Down

0 comments on commit c74623d

Please sign in to comment.