mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-24 03:59:08 -05:00
Apply fixes from StyleCI
This commit is contained in:
@@ -1,22 +1,22 @@
|
||||
<?php
|
||||
/**
|
||||
* NOTICE OF LICENSE
|
||||
* NOTICE OF LICENSE.
|
||||
*
|
||||
* UNIT3D is open-sourced software licensed under the GNU General Public License v3.0
|
||||
* The details is bundled with this project in the file LICENSE.txt.
|
||||
*
|
||||
* @project UNIT3D
|
||||
*
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
* @author HDVinnie
|
||||
*/
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Repositories\ChatRepository;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Requests\VoteOnPoll;
|
||||
use App\Poll;
|
||||
use App\Option;
|
||||
use App\Poll;
|
||||
use App\Repositories\ChatRepository;
|
||||
use App\Voter;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
|
||||
@@ -33,10 +33,10 @@ class PollController extends Controller
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* PollController Constructor
|
||||
* PollController Constructor.
|
||||
*
|
||||
* @param ChatRepository $chat
|
||||
* @param Toastr $toastr
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(ChatRepository $chat, Toastr $toastr)
|
||||
{
|
||||
@@ -45,7 +45,7 @@ class PollController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Show All Polls
|
||||
* Show All Polls.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
@@ -57,9 +57,10 @@ class PollController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Show A Poll
|
||||
* Show A Poll.
|
||||
*
|
||||
* @param $slug
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function show($slug)
|
||||
@@ -69,7 +70,7 @@ class PollController extends Controller
|
||||
$user_has_voted = $poll->voters->where('user_id', $user->id)->isNotEmpty();
|
||||
|
||||
if ($user_has_voted) {
|
||||
return redirect('poll/' . $poll->slug . '/result')
|
||||
return redirect('poll/'.$poll->slug.'/result')
|
||||
->with($this->toastr->info('You have already vote on this poll. Here are the results.', 'Hey There!', ['options']));
|
||||
}
|
||||
|
||||
@@ -77,9 +78,10 @@ class PollController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Vote On A Poll
|
||||
* Vote On A Poll.
|
||||
*
|
||||
* @param VoteOnPoll $request
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function vote(VoteOnPoll $request)
|
||||
@@ -92,7 +94,7 @@ class PollController extends Controller
|
||||
}
|
||||
|
||||
if (Voter::where('user_id', $user->id)->where('poll_id', $poll->id)->exists()) {
|
||||
return redirect('poll/' . $poll->slug . '/result')
|
||||
return redirect('poll/'.$poll->slug.'/result')
|
||||
->with($this->toastr->error('Bro have already vote on this poll. Your vote has not been counted.', 'Whoops!', ['options']));
|
||||
}
|
||||
|
||||
@@ -100,7 +102,7 @@ class PollController extends Controller
|
||||
$vote = new Voter();
|
||||
$vote->poll_id = $poll->id;
|
||||
$vote->user_id = $user->id;
|
||||
$vote->ip_address =$request->ip();
|
||||
$vote->ip_address = $request->ip();
|
||||
$vote->save();
|
||||
}
|
||||
|
||||
@@ -111,22 +113,23 @@ class PollController extends Controller
|
||||
":robot: [b][color=#fb9776]System[/color][/b] : [url={$profile_url}]{$user->username}[/url] has voted on poll [url={$poll_url}]{$poll->title}[/url]"
|
||||
);
|
||||
|
||||
return redirect('poll/' . $poll->slug . '/result')
|
||||
return redirect('poll/'.$poll->slug.'/result')
|
||||
->with($this->toastr->success('Your vote has been counted.', 'Yay!', ['options']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show A Polls Results
|
||||
* Show A Polls Results.
|
||||
*
|
||||
* @param $slug
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function result($slug)
|
||||
{
|
||||
$poll = Poll::whereSlug($slug)->firstOrFail();
|
||||
$map = [
|
||||
'poll' => $poll,
|
||||
'total_votes' => $poll->totalVotes()
|
||||
'poll' => $poll,
|
||||
'total_votes' => $poll->totalVotes(),
|
||||
];
|
||||
|
||||
return view('poll.result', $map);
|
||||
|
||||
Reference in New Issue
Block a user