Skip to content

Commit

Permalink
fix(regression): discussion creation fails
Browse files Browse the repository at this point in the history
  • Loading branch information
SychO9 committed Nov 4, 2024
1 parent b3a4011 commit ffea0db
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion framework/core/src/Api/Resource/DiscussionResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public function sorts(): array
/** @param Discussion $model */
public function creating(object $model, \Tobyz\JsonApiServer\Context $context): ?object
{
return Discussion::start(null, $context->getActor());
return Discussion::start(null, $context->getActor(), $model);
}

/** @param Discussion $model */
Expand Down
8 changes: 2 additions & 6 deletions framework/core/src/Discussion/Discussion.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,9 @@ public static function boot()
/**
* Start a new discussion. Raises the DiscussionWasStarted event.
*/
public static function start(?string $title, User $user): static
public static function start(?string $title, User $user, self $model = null): static
{
$discussion = new static;

if ($title) {
$discussion->title = $title;
}
$discussion = $model ?? new static;

$discussion->created_at = Carbon::now();
$discussion->user_id = $user->id;
Expand Down

0 comments on commit ffea0db

Please sign in to comment.