コード例 #1
0
ファイル: VoteController.php プロジェクト: vangogogo/justsns
 /**
  * 我的投票
  */
 public function actionMy()
 {
     $uid = Yii::app()->user->id;
     $model = new Vote();
     //初始化
     $criteria = new CDbCriteria();
     $criteria->order = 'ctime DESC';
     $criteria->condition = "uid=:uid";
     $criteria->params = array(':uid' => $uid);
     $mini = $model->find($criteria);
     $icon_list = Smile::model()->findAll();
     $date = Yii::app()->request->getQuery('date');
     if (!empty($date)) {
         $criteria = $model->fileaway($date, $criteria);
     }
     //取得数据总数,分页显示
     $total = $model->count($criteria);
     $pages = new CPagination($total);
     $pages->pageSize = self::PAGE_SIZE;
     $pages->applyLimit($criteria);
     //获取数据集
     $list = $model->findAll($criteria);
     $data = array('list' => $list, 'pages' => $pages, 'mini' => $mini, 'icon_list' => $icon_list);
     $this->render('my', $data);
 }
コード例 #2
0
ファイル: routes.php プロジェクト: sandy7772266/vote_test6
});
Route::get('/test', function () {
    // $artist = new Artist;
    // $artist->name = 'Eve 6';
    // $artist->save();
    // $candidate = new Candidate;
    // $candidate->cname=$data_array1[0];
    // $candidate->job_title=$data_array1[1];
    // $candidate->sex=$data_array1[2];
    // $candidate->vote_id=42;
    // $candidate->total_count=0;
    // $account = new Account;
    // $account->username;
    // $account->vote_id;
    // $account->finish_at;
    $vote = Vote::find(49);
    $account = new Account();
    $account->username = '******';
    $account->vote_id = 49;
    $account->finish_at = "0000-00-00 00:00:00";
    $account->vote()->associate($vote);
    $account->save();
    $account2 = new Account();
    $account2->username = '******';
    $account2->vote_id = 2;
    $account2->finish_at = "0000-00-00 00:00:00";
    $account2->vote()->associate($vote);
    $account2->save();
    $candidate = new Candidate();
    $candidate->cname = 'Naruto Uzumaki';
    $candidate->job_title = 'yy';
コード例 #3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     //
     $vote = Vote::find($id);
     $vote->delete();
     $arr = ['flash' => ['type' => 'success', 'msg' => '待辦事項已刪除!']];
     return Redirect::route('home');
 }
コード例 #4
0
 /**
  * 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');
 }