Skip to content

Commit

Permalink
Fix poll creation not saving multiple votes or max votes options
Browse files Browse the repository at this point in the history
  • Loading branch information
dsevillamartin committed Jun 14, 2023
1 parent 361d6b1 commit 57158cc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions js/src/forum/components/CreatePollModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ export default class CreatePollModal extends Modal {
endDate: this.endDate(),
publicPoll: this.publicPoll(),
allowMultipleVotes: this.allowMultipleVotes(),
maxVotes: this.maxVotes(),
options: [],
};

Expand Down
4 changes: 3 additions & 1 deletion src/Listeners/SavePollsToDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ public function handle(Saving $event)
$discussion->id,
$event->actor->id,
$endDate !== null ? Carbon::createFromTimeString($endDate) : null,
Arr::get($attributes, 'publicPoll')
Arr::get($attributes, 'publicPoll'),
Arr::get($attributes, 'allowMultipleVotes'),
Arr::get($attributes, 'maxVotes')
);

$this->events->dispatch(new SavingPollAttributes($event->actor, $poll, $attributes, $event->data));
Expand Down
4 changes: 3 additions & 1 deletion src/Poll.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Poll extends AbstractModel
*
* @return static
*/
public static function build($question, $discussionId, $actorId, $endDate, $publicPoll)
public static function build($question, $discussionId, $actorId, $endDate, $publicPoll, $allowMultipleVotes = false, $maxVotes = 0)
{
$poll = new static();

Expand All @@ -66,6 +66,8 @@ public static function build($question, $discussionId, $actorId, $endDate, $publ
$poll->user_id = $actorId;
$poll->end_date = $endDate;
$poll->public_poll = $publicPoll;
$poll->allow_multiple_votes = $allowMultipleVotes;
$poll->max_votes = $maxVotes;

return $poll;
}
Expand Down

0 comments on commit 57158cc

Please sign in to comment.