/** * Execute the console command. * * @return mixed */ public function fire() { $this->info('Iniciando a requisição para o webservice'); $this->info('Carregando a lista de estados'); $estados = $this->makeRequest('estados'); $this->info('Foram encontrados ' . count($estados) . ' estados'); $this->info('Carregando a lista de cargos'); $cargos = CandidateType::all()->lists('id', 'type'); $this->info('Foram encontrados ' . count($cargos) . ' cargos'); $this->info('Carregando a lista de partidos'); $partidos = Party::all()->lists('id', 'abbreviation'); $this->info('Foram encontrados ' . count($partidos) . ' partidos'); foreach ($estados as $estado_id => $estado) { $this->info("Carregando os candidatos de {$estado->sigla} ({$estado_id}/" . count($estado) . ")"); foreach ($cargos as $cargo_nome => $cargo_id) { $this->info('- Procurando por ' . $cargo_nome); $candidatos = $this->makeRequest('candidatos', ['estado' => $estado->sigla, 'cargo' => $cargo_id]); foreach ($candidatos as $candidato) { $candidate = Candidate::where('full_name', $candidato->nome)->first(); if (!$candidate) { $this->info('-- Processando ' . $candidato->nome . '/' . $candidato->apelido); $picture_hash = Str::random(90) . ".jpg"; file_put_contents(app_path() . '/../www/uploads/' . $picture_hash, file_get_contents($candidato->foto)); Candidate::create(['party_id' => $partidos[$candidato->partido], 'candidate_type_id' => $cargos[ucfirst(strtolower(str_replace('º', '', (string) $candidato->cargo)))], 'nickname' => $candidato->apelido, 'full_name' => $candidato->nome, 'picture' => $picture_hash]); } } //$this->info('Foram encontrados ' . count($candidatos) . ' candidatos'); } } }
public function getVoterVoteNext($postid) { $post = Post::where('id', '>', $postid)->where('Active', '=', TRUE); if ($post->count()) { $post = $post->first(); View::share('post', $post); //get the candidates vieing fot the post $candidates = Candidate::where('Posts_Id', '=', $post->id)->get(); View::share('candidates', $candidates); return View::make('voter.voter-vote-next'); } else { return Redirect::route('voter-home-get')->with('globalsuccess', 'Thanks for Voting'); } }
<td><br>投票已完成...<br><a href="{{ url('/vote_result_show', array($vote->id), false) }}"><strong>{{$vote->vote_title}}<br>now:{{$time_now}}<br>start:{{$vote->start_at}}end:{{$vote->end_at}}</strong></a><br> </td> @elseif ( $time_now > $vote->start_at) <td ><br>投票進行中... <a href="{{ url('/account_data_show', array($vote->id), false) }}"><strong>籤票內容</strong></a> <br><a href="{{ url('/vote_result_show', array($vote->id), false) }}"><strong>{{$vote->vote_title}}<br>now:{{$time_now}}<br>start:{{$vote->start_at}}end:{{$vote->end_at}}</strong></a><br> <br><strong>{{$vote->vote_title}}<br>now:{{$time_now}}<br>start:{{$vote->start_at}}end:{{$vote->end_at}}</strong><br> </td> @else <td ><br>尚未投票...<br><strong>{{$vote->vote_title}}<br>now:{{$time_now}}<br>start:{{$vote->start_at}}end:{{$vote->end_at}}</strong> <?php $candidates = Candidate::where('vote_id', '=', $vote->id)->get(); $can_id = null; if (count($candidates) != 0) { $can_id = $candidates[0]->id; } ?> <li class="list-group-item"> <table> <tr> <td > @if ($ary[1][$vote->id]<>'沒有資料') <!-- {{$ary[1][$vote->id]}} --> <a href="{{ url('/candidate_data_show', array($vote->id), false) }}"><strong>瀏覽選項內容</strong></a>
//$redo = 1; echo "id", $votes[0]->{$id}, "amount", $votes[0]->vote_amount; Session::put('vote_data', $vote_data); Session::put('redo', 1); })); Route::get('/account_data_del/{id}', ['as' => 'account_data_del', 'uses' => 'AccountController@clean']); // Route::get('/{id}/{s}', array('as' => 'vote.edit2', function($id,$s) // { // // return our view and Vote information // // return View::make('tasks.vote-edit') // pulls app/views/nerd-edit.blade.php // // ->with('vote', Vote::find($id)); // return View::make('tasks.vote-edit2', array('id' => $id,'s'=>$s,'vote'=>Vote::find($id))); // })); Route::get('/test3', function () { $vote = Vote::find(51); $candidates = Candidate::where('vote_id', '=', 54)->get(); foreach ($candidates as $candidate) { $dump_d = Candidate::with('accounts')->find($candidate->id); dd($dump_d); } // $account = Account::find(1); // $candidate = Candidate::find(10); // $candidate->accounts()->detach(); // // return $candidate->accounts; // return Candidate::with('accounts')->find($candidate->id); }); Route::get('/test4', function () { $vote = Vote::find(51); $time2 = $vote->start_at; $time3 = Carbon::now(); printf("Now: %s", $time2);
public function clean($vote_id) { Candidate::where('vote_id', '=', $vote_id)->delete(); $arr = ['status' => 'success', 'msg' => '完成事項已刪除!']; return Response::json($arr); }
public function resetPassword($candidate_id, $password_reset_code) { $candidate = Candidate::where('id', $candidate_id)->where('password_reset_code', $password_reset_code)->first(); if (!is_null($candidate)) { $password = Input::get('password'); $candidate->password = Hash::make($password); $candidate->save(); return Redirect::to('/')->withInfo('Your password has now been reset.'); } return Redirect::to('/')->withInfo('There was an error.'); }
public function getPaginateCandidatesAttribute() { return Candidate::where('category_id', $this->id)->paginate(); }
function login() { $username = $this->input->post('username'); $password = md5($this->input->post('password')); $o = new Candidate(); $o->where(array('username' => $username, 'password' => $password)); $o->get_iterated(); if ($o->result_count() == 0) { } else { } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { // $vote = Vote::find($id); $candidates = Candidate::where('vote_id', '=', $id)->get(); foreach ($candidates as $candidate) { $candidate->accounts()->detach(); $candidate->delete(); } Account::where('vote_id', '=', $id)->delete(); $vote->delete(); $arr = ['flash' => ['type' => 'success', 'msg' => '待辦事項已刪除!']]; return Redirect::route('votes_not_yet'); }
public function postEditCandidate() { //verify the user input $validator = Validator::make(Input::all(), array('Post' => '', 'Motto' => '')); if ($validator->fails()) { return Redirect::route('admin-view-candidates-get')->with('globalerror', 'Please Try Again'); } else { $candidate_id = Input::get('Candidate_ID'); $candidate = Candidate::where('id', '=', $candidate_id)->first(); $post = Input::get('Post'); $motto = Input::get('Motto'); $candidate->Post = $post; $candidate->Motto = $motto; if ($voter->save()) { return Redirect::route('admin-view-elections-get')->with('globalsuccess', 'Voter Details have been edited'); } } }