Skip to content

Commit

Permalink
Fix issue with L8 and not showing options before voting
Browse files Browse the repository at this point in the history
  • Loading branch information
El Houssain INANI committed Jun 5, 2021
1 parent b14d971 commit 77fdc1c
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 78 deletions.
8 changes: 3 additions & 5 deletions src/Helpers/PollWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,15 @@ public function draw($poll)
return 'To start soon';
}

if (!$poll->showResultsEnabled()) {
return 'Thanks for voting';
}


$voter = $poll->canGuestVote() ? new Guest(request()) : auth(config('larapoll_config.admin_guard'))->user();

if (is_null($voter) || $voter->hasVoted($poll->id) || $poll->isLocked()) {
if (!$poll->showResultsEnabled()) {
return 'Thanks for voting';
}
return $this->drawResult($poll);
}

if ($poll->isRadio()) {
return $this->drawRadio($poll);
}
Expand Down
133 changes: 60 additions & 73 deletions src/LarapollServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,73 +1,60 @@
<?php
namespace Inani\Larapoll;

use Illuminate\Support\ServiceProvider;
use Inani\Larapoll\Helpers\PollWriter;
use Illuminate\Database\Eloquent\Factory;

class LarapollServiceProvider extends ServiceProvider
{

/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->registerPollWriter();
}

/**
* Boot What is needed
*
*/
public function boot()
{
// migrations
$this->publishes([
__DIR__ . '/database/migrations/2017_01_23_115718_create_polls_table.php'
=> base_path('database/migrations/2017_01_23_115718_create_polls_table.php'),
__DIR__ . '/database/migrations/2017_01_23_124357_create_options_table.php'
=> base_path('database/migrations/2017_01_23_124357_create_options_table.php'),
__DIR__ . '/database/migrations/2017_01_25_111721_create_votes_table.php'
=> base_path('database/migrations/2017_01_25_111721_create_votes_table.php'),
__DIR__ . '/database/migrations/2019_04_20_145921_schema_changes.php'
=> base_path('database/migrations/2019_04_20_145921_schema_changes.php'),
]);
// load factories
$this->registerFactories();
// routes
$this->loadRoutesFrom(__DIR__ . '/Http/routes.php');
// views
$this->loadViewsFrom(__DIR__ . '/views', 'larapoll');

$this->publishes([
__DIR__ . '/config/config.php' => config_path('larapoll_config.php'),
]);
}

/**
* Register the poll writer instance.
*
* @return void
*/
protected function registerPollWriter()
{
$this->app->singleton('pollwritter', function ($app) {
return new PollWriter();
});
}

/**
* Register an additional directory of factories.
*
* @return void
*/
public function registerFactories()
{
if (!app()->environment('production')) {
app(Factory::class)->load(__DIR__ . '/database/factories');
}
}
}
<?php
namespace Inani\Larapoll;

use Illuminate\Support\ServiceProvider;
use Inani\Larapoll\Helpers\PollWriter;
use Illuminate\Database\Eloquent\Factories\Factory;

class LarapollServiceProvider extends ServiceProvider
{

/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->registerPollWriter();
}

/**
* Boot What is needed
*
*/
public function boot()
{
// migrations
$this->publishes([
__DIR__ . '/database/migrations/2017_01_23_115718_create_polls_table.php'
=> base_path('database/migrations/2017_01_23_115718_create_polls_table.php'),
__DIR__ . '/database/migrations/2017_01_23_124357_create_options_table.php'
=> base_path('database/migrations/2017_01_23_124357_create_options_table.php'),
__DIR__ . '/database/migrations/2017_01_25_111721_create_votes_table.php'
=> base_path('database/migrations/2017_01_25_111721_create_votes_table.php'),
__DIR__ . '/database/migrations/2019_04_20_145921_schema_changes.php'
=> base_path('database/migrations/2019_04_20_145921_schema_changes.php'),
]);
// routes
$this->loadRoutesFrom(__DIR__ . '/Http/routes.php');
// views
$this->loadViewsFrom(__DIR__ . '/views', 'larapoll');

$this->publishes([
__DIR__ . '/config/config.php' => config_path('larapoll_config.php'),
]);
}

/**
* Register the poll writer instance.
*
* @return void
*/
protected function registerPollWriter()
{
$this->app->singleton('pollwritter', function ($app) {
return new PollWriter();
});
}

}

0 comments on commit 77fdc1c

Please sign in to comment.