當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Survey::all方法代碼示例

本文整理匯總了PHP中Survey::all方法的典型用法代碼示例。如果您正苦於以下問題:PHP Survey::all方法的具體用法?PHP Survey::all怎麽用?PHP Survey::all使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Survey的用法示例。


在下文中一共展示了Survey::all方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: get

 /**
  * Get survey(s)
  * 
  * Call examples :
  *  /survey : get all survey the user can view TODO check heaviness
  *  /survey/<id> : get survey from its id
  * 
  * @param int $id survey id
  * 
  * @return mixed
  * 
  * @throws RestBadParameterException
  * @throws RestOwnershipRequiredException
  * @throws RestSurveyNotFoundException
  * @throws RestNotAllowedException
  */
 public static function get($id = null)
 {
     if ($id) {
         // Trying to get a single survey
         try {
             $survey = Survey::fromId($id);
         } catch (NotFoundException $e) {
             throw new RestSurveyNotFoundException($id);
         }
         // Check permission
         if (!$survey->can->view) {
             throw new RestNotAllowedException('view survey ' . $survey->id);
         }
         return self::cast($survey);
     }
     $surveys = array();
     foreach (Survey::all() as $survey) {
         if (!Auth::isAuthenticated()) {
             continue;
         }
         if (!Auth::isAdmin() && !Auth::user()->is($survey->owner)) {
             continue;
         }
         if (!$survey->can->view) {
             continue;
         }
         $surveys[] = self::cast($survey);
     }
     return $surveys;
 }
開發者ID:eheb,項目名稱:renater-decide,代碼行數:46,代碼來源:SurveyEndpoint.class.php

示例2: sandbox

 public static function sandbox()
 {
     // Testaa koodiasi täällä
     $eka = Survey::find(1);
     $kaikki = Survey::all();
     Kint::dump($eka);
     Kint::dump($kaikki);
 }
開發者ID:banjohirvi,項目名稱:Tsoha-Bootstrap,代碼行數:8,代碼來源:hello_world_controller.php

示例3: index

 public static function index()
 {
     if (!self::check_logged_in()) {
         Redirect::to('/login', array('error' => 'You must log in to access this resource.'));
         return;
     }
     $surveys = Survey::all();
     $results = Result::all();
     View::make('survey/index.html', array('surveys' => $surveys, 'results' => $results));
 }
開發者ID:banjohirvi,項目名稱:Tsoha-Bootstrap,代碼行數:10,代碼來源:survey_controller.php

示例4: updateGroup

 /**
  * This will handle both updating and deleting group
  */
 public function updateGroup()
 {
     if ($_POST) {
         if (Input::has('delete')) {
             $group = Group::find(Input::get('id'));
             if (is_null($group)) {
                 return Redirect::to('groups/manage');
             }
             $group->delete();
             return Redirect::to('groups/manage');
         } elseif (Input::has('edit')) {
             $group = Group::find(Input::get('id'));
             if (is_null($group)) {
                 return Redirect::to('groups/manage');
             }
             return Redirect::to('group/edit')->with('update_group', $group);
         } elseif (Input::has('addremusers')) {
             $group = Group::find(Input::get('id'));
             if (is_null($group)) {
                 return Redirect::to('groups/manage');
             }
             return Redirect::action('GroupController@manageUsers', array('id' => $group->id));
         } elseif (Input::has('update')) {
             $group = Group::find(Input::get('id'));
             if (is_null($group)) {
                 return Redirect::to('groups/manage');
             }
             $group->name = Input::get('name');
             $group->description = Input::get('description');
             $group->timestart = strtotime(Input::get('timestart'));
             $group->outcome = Input::get('outcome');
             $group->survey = Input::get('survey');
             $group->postsurvey = Input::get('postsurvey');
             if (Input::hasFile('thumbnail')) {
                 $file = Input::file('thumbnail');
                 $pixpath = '/uploads/pix/group/';
                 $destinationPath = public_path() . $pixpath;
                 $filename = str_replace(" ", "_", $group->name) . '.' . $file->getClientOriginalExtension();
                 $file->move($destinationPath, $filename);
                 $group->thumbnail = base64_encode($pixpath . $filename);
             }
             $group->save();
             return Redirect::to('groups/manage');
         }
     }
     $group = Session::get('update_group');
     if (is_null($group)) {
         return Redirect::to('groups/manage');
     }
     //Outcome menu
     $outcomes = Outcome::all();
     $outcomes_menu = array();
     $outcomes_menu[0] = trans('master.choose');
     foreach ($outcomes as $outcome) {
         $outcomes_menu[$outcome->id] = trans($outcome->name);
     }
     //Survey menu
     $surveys = Survey::all();
     $surveys_menu = array();
     $surveys_menu[0] = trans('master.choose');
     foreach ($surveys as $survey) {
         $surveys_menu[$survey->id] = trans($survey->name);
     }
     return $this->layout->content = View::make('group.edit')->with('outcomes', $outcomes_menu)->with('surveys', $surveys_menu)->with('group', $group);
 }
開發者ID:RHoKAustralia,項目名稱:onaroll21_backend,代碼行數:68,代碼來源:GroupController.php

示例5: manageSurveys

 public function manageSurveys()
 {
     // TODO: this function will list the surveys
     $surveys = Survey::all();
     $this->layout->content = View::make('survey.manage')->with('surveys', $surveys);
 }
開發者ID:RHoKAustralia,項目名稱:onaroll21_backend,代碼行數:6,代碼來源:SurveyController.php


注:本文中的Survey::all方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。