(Update) Refactor Validation Error/Info/Warning/Success Handeling 🚀

This commit is contained in:
HDVinnie
2019-03-25 13:53:41 -04:00
parent 08c4adcc1c
commit c382aa5236
81 changed files with 882 additions and 1371 deletions
+4 -12
View File
@@ -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.');
}
/**