mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-29 23:09:42 -05:00
(Update) Refactor Validation Error/Info/Warning/Success Handeling 🚀
This commit is contained in:
@@ -16,7 +16,6 @@ namespace App\Http\Controllers;
|
||||
use App\Models\Poll;
|
||||
use App\Models\Voter;
|
||||
use App\Models\Option;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use App\Http\Requests\VoteOnPoll;
|
||||
use App\Repositories\ChatRepository;
|
||||
|
||||
@@ -27,21 +26,14 @@ class PollController extends Controller
|
||||
*/
|
||||
private $chat;
|
||||
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* PollController Constructor.
|
||||
*
|
||||
* @param ChatRepository $chat
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(ChatRepository $chat, Toastr $toastr)
|
||||
public function __construct(ChatRepository $chat)
|
||||
{
|
||||
$this->chat = $chat;
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +63,7 @@ class PollController extends Controller
|
||||
|
||||
if ($user_has_voted) {
|
||||
return redirect('poll/'.$poll->slug.'/result')
|
||||
->with($this->toastr->info('You have already vote on this poll. Here are the results.', 'Hey There!', ['options']));
|
||||
->withInfo('You have already vote on this poll. Here are the results.');
|
||||
}
|
||||
|
||||
return view('poll.show', compact('poll'));
|
||||
@@ -95,7 +87,7 @@ class PollController extends Controller
|
||||
|
||||
if (Voter::where('user_id', '=', $user->id)->where('poll_id', '=', $poll->id)->exists()) {
|
||||
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']));
|
||||
->withErros('Bro have already vote on this poll. Your vote has not been counted.');
|
||||
}
|
||||
|
||||
if ($poll->ip_checking == 1) {
|
||||
@@ -114,7 +106,7 @@ class PollController extends Controller
|
||||
);
|
||||
|
||||
return redirect('poll/'.$poll->slug.'/result')
|
||||
->with($this->toastr->success('Your vote has been counted.', 'Yay!', ['options']));
|
||||
->withSuccess('Your vote has been counted.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user