コード例 #1
0
 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();
 }
コード例 #2
0
 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);
 }
コード例 #3
0
ファイル: Poll.php プロジェクト: Vatia13/gbtimes
 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';
     }
 }
コード例 #4
0
ファイル: PollTest.php プロジェクト: umSoftEng2GrpE/partEZ
 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();
 }
コード例 #5
0
 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();
 }
コード例 #6
0
ファイル: PollsController.php プロジェクト: Vatia13/gbtimes
 /**
  * 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'));
 }
コード例 #7
0
 /**
  * Show the application dashboard.
  *
  * @return Response
  */
 public function index()
 {
     $polls = Poll::where('owner_id', '=', Auth::id())->get();
     return view('home')->with('polls', $polls);
 }