(Update) Poll System

This commit is contained in:
HDVinnie
2018-06-06 23:47:25 -04:00
parent a29b027953
commit af74ba7678
3 changed files with 55 additions and 37 deletions
+23 -11
View File
@@ -17,7 +17,6 @@ use App\Repositories\ChatRepository;
use Illuminate\Http\Request;
use App\Poll;
use App\Option;
use App\Message;
use App\Http\Requests\StorePoll;
use Cache;
use \Toastr;
@@ -34,20 +33,32 @@ class PollController extends Controller
$this->chat = $chat;
}
/**
* Show All Polls
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function polls()
{
$polls = Poll::latest()->paginate(25);
return view('Staff.poll.polls', compact('polls'));
}
public function poll($id)
{
$poll = Poll::where('id', $id)->firstOrFail();
return view('Staff.poll.poll', compact('poll'));
return view('Staff.poll.polls', ['polls' => $polls]);
}
/**
* Show the form for creating a new resource.
* Show A Poll
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function poll($id)
{
$poll = Poll::where('id', $id)->firstOrFail();
return view('Staff.poll.poll', ['poll' => $poll]);
}
/**
* Poll Add Form
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
@@ -57,10 +68,10 @@ class PollController extends Controller
}
/**
* Store a newly created resource in storage.
* Add A Poll
*
* @param StorePoll $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
* @return Illuminate\Http\RedirectResponse
*/
public function store(StorePoll $request)
{
@@ -86,6 +97,7 @@ class PollController extends Controller
"A new poll has been created [url={$poll_url}]{$poll->title}[/url] vote on it now! :slight_smile:"
);
return redirect('poll/' . $poll->slug)->with(Toastr::success('Your poll has been created.', 'Yay!', ['options']));
return redirect('poll/' . $poll->slug)
->with(Toastr::success('Your poll has been created.', 'Yay!', ['options']));
}
}