当前位置: 首页>>代码示例>>PHP>>正文


PHP Survey::where方法代码示例

本文整理汇总了PHP中Survey::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Survey::where方法的具体用法?PHP Survey::where怎么用?PHP Survey::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Survey的用法示例。


在下文中一共展示了Survey::where方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($schoolName, $surveyName)
 {
     $school = School::where('name', '=', $schoolName)->first();
     if (!$school) {
         return Redirect::to('/schools/');
     }
     $survey = Survey::where('name', '=', $surveyName)->first();
     if (!$survey) {
         return Redirect::to("/schools/{$schoolName}");
     }
     $groupStats = array();
     foreach (Group::all() as $group) {
         $possibleLink = $group->surveys()->where('survey_id', $survey->id)->first();
         $active = !is_null($possibleLink);
         $groupInfo = array('group' => $group, 'open_time' => 'no time set', 'close_time' => 'no time set');
         if ($active) {
             $active = strtotime($possibleLink->pivot->open_time) < time() && strtotime($possibleLink->pivot->close_time) > time();
             if (strtotime($possibleLink->pivot->open_time)) {
                 $groupInfo['open_time'] = $possibleLink->pivot->open_time;
             }
             if (strtotime($possibleLink->pivot->close_time)) {
                 $groupInfo['close_time'] = $possibleLink->pivot->close_time;
             }
         }
         $groupInfo['active'] = $active;
         array_push($groupStats, $groupInfo);
     }
     return View::make('content.surveyShow')->with('school', $school)->with('survey', $survey)->with('groupStats', $groupStats);
 }
开发者ID:AlexLeung,项目名称:ibsurvey,代码行数:35,代码来源:SurveysController.php

示例2: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($schoolName, $surveyName, $groupName)
 {
     if (Input::has('password')) {
         return Redirect::to(Request::path())->with('password', Input::get('password'));
     } else {
         if (Input::has('passwordSubmit')) {
             return Redirect::to(Request::path())->with('emptyError', 1);
         } else {
             if (Session::has('emptyError')) {
                 return View::make('content.surveyGroupShow')->with('error', 'You must enter a password.');
             }
         }
     }
     //Loading all questions for a particular survey and group.
     $school = School::where('name', '=', $schoolName)->first();
     if (!$school) {
         return Redirect::to('/schools');
     }
     $survey = Survey::where('name', '=', $surveyName)->where('school_id', $school->id)->first();
     if (!$survey) {
         return Redirect::to("/schools/{$schoolName}");
     }
     $group = $survey->groups()->where('name', $groupName)->first();
     if (!$group || strtotime($group->pivot->open_time) > time() || strtotime($group->pivot->close_time) < time()) {
         return Redirect::to("schools/{$schoolName}/{$surveyName}");
     }
     $loggedIn = Auth::check();
     if ($loggedIn) {
         $user = Auth::user();
         $authName = $user->group->name;
         if ($authName != $groupName) {
             $firstAn = "a";
             $secondAn = "a";
             if (strstr("aeiou", strtolower($authName[0]))) {
                 $firstAn = "an";
             }
             if (strstr("aeiou", strtolower($groupName[0]))) {
                 $secondAn = "an";
             }
             return View::make('content.surveyGroupShow')->with('state', 'error')->with('error', "You are currently logged into {$firstAn} {$authName} account, and not {$secondAn} {$groupName} account.");
         }
         if ($user->name == "Anonymous" && !Session::has('remainAnon')) {
             return View::make('content.surveyGroupShow')->with('state', 'options');
         }
         $questionStore = Survey::parseQuestionStore(File::get(app_path() . "/questions/{$survey->id}.qs"), $school->id, true);
         if (!$questionStore[0]) {
             throw new Exception("Problem getting question file parsed.");
         }
         $path = app_path() . "/answers/{$user->id}.ans";
         $answers = array();
         if (File::exists($path)) {
             $answers = json_decode(File::get($path), true)[$user->id];
         }
         //dd($answers);
         return View::make('content.surveyGroupShow')->with('answers', $answers)->with('state', 'survey')->with('message', "This is the {$surveyName} survey for all members of the {$groupName} group.")->with('questionStore', $questionStore[1])->with('groupName', $group->name)->with('closeTime', $group->pivot->close_time);
     } else {
         if ($groupName == "Admin") {
             return View::make('content.surveyGroupShow')->with('state', 'error')->with('error', "You must be logged in as an Admin to take the Admin survey.");
         } else {
             if (Session::has('password')) {
                 if (Hash::check(Session::get('password'), $group->password)) {
                     return View::make('content.surveyGroupShow')->with('state', 'options');
                 } else {
                     return View::make('content.surveyGroupShow')->with('error', 'You entered the wrong password. Try again.');
                 }
             } else {
                 return View::make('content.surveyGroupShow');
             }
         }
     }
 }
开发者ID:AlexLeung,项目名称:ibsurvey,代码行数:77,代码来源:GroupsController.php

示例3: getSurveyList

 public function getSurveyList()
 {
     $input = Input::all();
     if ($input['type'] == 'pre') {
         $group = Group::where('id', $input['groupid'])->pluck('survey');
         //print_r($group);
         $survey = Survey::where('id', $group)->get();
     } else {
         $group = Group::where('id', $input['groupid'])->pluck('postsurvey');
         $survey = Survey::where('id', $group)->get();
     }
     $ret = str_replace('{"fields":', "", rtrim(unserialize($survey[0]->data)[0]));
     $ret = rtrim($ret, "}");
     return $ret;
 }
开发者ID:RHoKAustralia,项目名称:onaroll21_backend,代码行数:15,代码来源:APIController.php


注:本文中的Survey::where方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。