Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/im/global-polls' into im/global-…
Browse files Browse the repository at this point in the history
…polls
  • Loading branch information
novacuum committed Mar 7, 2024
2 parents be6d2cf + 4fbb9bd commit 8b74d51
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/Api/Controllers/DeletePollOptionImageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace FoF\Polls\Api\Controllers;

use Flarum\Http\RequestUtil;
use FoF\Polls\Poll;
use FoF\Polls\PollOption;
use Illuminate\Contracts\Filesystem\Cloud;
use Illuminate\Contracts\Filesystem\Factory;
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Controllers/UploadPollImageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected function createLocalPath(string $filename, ?string $pollId): string
return $filename;
}

protected function linkToRecord(int $pollId, string $uploadName):void
protected function linkToRecord(int $pollId, string $uploadName): void
{
if ($pollId && $poll = Poll::find($pollId)) {
$poll->image = $uploadName;
Expand Down
5 changes: 3 additions & 2 deletions src/Api/Controllers/UploadPollOptionImageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ class UploadPollOptionImageController extends UploadPollImageController

protected function createLocalPath(string $filename, ?string $pollId): string
{
if(!$pollId) {
if (!$pollId) {
throw new \InvalidArgumentException('Poll ID is required');
}

return "pollOptions/{$pollId}/{$filename}";
}

protected function linkToRecord(int $pollId, string $uploadName):void
protected function linkToRecord(int $pollId, string $uploadName): void
{
if ($pollId && $pollOption = PollOption::find($pollId)) {
$pollOption->image = $uploadName;
Expand Down
1 change: 0 additions & 1 deletion src/Api/Serializers/PollOptionSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace FoF\Polls\Api\Serializers;

use Flarum\Api\Serializer\AbstractSerializer;
use FoF\Polls\Poll;
use FoF\Polls\PollOption;
use Illuminate\Contracts\Filesystem\Cloud;
use Illuminate\Contracts\Filesystem\Factory;
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/CreatePollHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function handle(CreatePoll $command)
foreach ($rawOptionsData as $rawOptionData) {
$optionsData[] = [
'answer' => Arr::get($rawOptionData, 'answer'),
'image' => Arr::get($rawOptionData, 'image'),
'image' => Arr::get($rawOptionData, 'image'),
'imageAlt' => Arr::get($rawOptionData, 'imageAlt'),
];
}
Expand Down
6 changes: 3 additions & 3 deletions src/Commands/EditPollHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ public function handle(EditPoll $command)

$optionAttributes = [
'answer' => Arr::get($opt, 'attributes.answer'),
'image' => Arr::get($opt, 'attributes.image') ?: null,
'imageAlt' => Arr::get($opt, 'attributes.imageAlt') ?: null
'image' => Arr::get($opt, 'attributes.image') ?: null,
'imageAlt' => Arr::get($opt, 'attributes.imageAlt') ?: null,
];

if (!$this->settings->get('fof-polls.allowOptionImage')) {
Expand All @@ -141,7 +141,7 @@ public function handle(EditPoll $command)
'id' => $id,
], [
'answer' => Arr::get($optionAttributes, 'answer'),
'image' => Arr::get($optionAttributes, 'image'),
'image' => Arr::get($optionAttributes, 'image'),
'image_alt' => Arr::get($optionAttributes, 'imageAlt'),
]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Validators/PollOptionValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected function getRules()
{
return [
'answer' => ['required', 'string', 'max:255'],
'image' => ['nullable', 'string', 'max:255'],
'image' => ['nullable', 'string', 'max:255'],
'imageAlt' => ['nullable', 'string', 'max:255'],
];
}
Expand Down

0 comments on commit 8b74d51

Please sign in to comment.