protected function tearDown() { PollResponse::where('pid', $this->pollOption->oid)->delete(); PollOption::where('oid', $this->pollOption->oid)->delete(); Poll::where('pid', $this->poll->pid)->delete(); Event::where('eid', $this->event->eid)->delete(); User::where('uid', $this->user->uid)->delete(); }
public function candidateAvg($candidate) { $sum = \App\Poll::where('state_id', $this->id)->sum($candidate); $parts = \App\Poll::where('state_id', $this->id)->count(); if ($parts == 0) { $parts = 1; } return number_format($sum / $parts, 2); }
public function pollStatus($poll) { if ($poll->status > 0) { $poll->update(['status' => '0']); return 'deactivated'; } else { Poll::where('status', '=', '1')->update(['status' => '0']); $poll->update(['status' => '1']); return 'activated'; } }
protected function tearDown() { if (is_null($this->lastPoll)) { $poll = Poll::first(); if (!is_null($poll)) { $poll->delete(); } } else { Poll::where('pid', '>', $this->lastPoll)->delete(); } Event::where('eid', $this->event->eid)->delete(); User::where('uid', $this->user->uid)->delete(); }
protected function tearDown() { if (is_null($this->lastPollOption)) { $option = PollOption::first(); if (!is_null($option)) { $option->delete(); } } else { PollOption::where('oid', '>', $this->lastPollOption)->delete(); } Poll::where('pid', $this->poll->pid)->delete(); Event::where('eid', $this->event->eid)->delete(); User::where('uid', $this->user->uid)->delete(); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id, PollRequest $request, Poll $polls) { $poll = $polls->findOrFail($id); $poll->update($request->all()); if (count($request->input('answer')) > 0) { $polls->where('parent_id', '=', $id)->delete(); foreach ($request->input('answer') as $answer) { $vote = $polls->create(['title' => $answer, 'parent_id' => $id]); DB::table('votes')->insert(['poll_id' => $vote->id, 'parent_id' => $id, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]); } } //$article->updateCat(['cat'=>$request->input('cat'),'id'=>$id]); flash()->success(trans('polls.updated')); return redirect(action('Admin\\PollsController@index')); }
/** * Show the application dashboard. * * @return Response */ public function index() { $polls = Poll::where('owner_id', '=', Auth::id())->get(); return view('home')->with('polls', $polls); }