Skip to content

Commit

Permalink
Create survey shortcode
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudio-Emmolo committed Dec 22, 2023
1 parent 42bd3bb commit f0df14d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
10 changes: 10 additions & 0 deletions resources/views/survey.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@foreach($ids as $id)
<div class="not-prose">
<livewire:nova-survey :id="$id" />
</div>
@endforeach

{{--
Required:
- Package: nova-survey-package on principal project
--}}
2 changes: 2 additions & 0 deletions src/LaravelShortcodePlusServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Murdercode\LaravelShortcodePlus\Shortcodes\RedditShortcode;
use Murdercode\LaravelShortcodePlus\Shortcodes\SpoilerShortcode;
use Murdercode\LaravelShortcodePlus\Shortcodes\SpotifyShortcode;
use Murdercode\LaravelShortcodePlus\Shortcodes\SurveyShortcode;
use Murdercode\LaravelShortcodePlus\Shortcodes\TikTokShortcode;
use Murdercode\LaravelShortcodePlus\Shortcodes\TmdbShortcode;
use Murdercode\LaravelShortcodePlus\Shortcodes\TwitterShortcode;
Expand Down Expand Up @@ -78,6 +79,7 @@ public function register(): void
Shortcode::register('button', ButtonShortcode::class);
Shortcode::register('tmdb', TmdbShortcode::class);
Shortcode::register('tiktok', TikTokShortcode::class);
Shortcode::register('survey', SurveyShortcode::class);

}
}
17 changes: 17 additions & 0 deletions src/Shortcodes/SurveyShortcode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Murdercode\LaravelShortcodePlus\Shortcodes;

class SurveyShortcode
{
public function register($shortcode): string
{
$ids =explode(',', $shortcode->id) ?? '';

Check failure on line 9 in src/Shortcodes/SurveyShortcode.php

View workflow job for this annotation

GitHub Actions / phpstan

Expression on left side of ?? is not nullable.

if (empty($ids)) {

Check failure on line 11 in src/Shortcodes/SurveyShortcode.php

View workflow job for this annotation

GitHub Actions / phpstan

Variable $ids in empty() always exists and is not falsy.
return 'No Survey parameter id defined';
}

return view('shortcode-plus::survey', compact('ids'))->render();
}
}

0 comments on commit f0df14d

Please sign in to comment.