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


PHP Subject::findOrFail方法代碼示例

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


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

示例1: update

 private function update($id)
 {
     $subject = Subject::findOrFail($id);
     $subject->subjectname = Input::get('name');
     $subject->subjectcode = Input::get('code');
     $subject->grade = Input::get('grade');
     $subject->save();
 }
開發者ID:eufelipemartins,項目名稱:edlara,代碼行數:8,代碼來源:SubjectController.php

示例2: array

$tutorialid = Session::get('tutorialid', 1);
$tutoriallist = array();
// $tutorial = Tutorials::where('id','=',$tutorialid);
// var_dump($tutorial);
if ($tutorialid !== NULL) {
    $tutorial = Tutorials::findOrFail($tutorialid);
    $tutoriallist[$tutorial->id] = $tutorial->name;
    $teacher = User::findOrFail($tutorial->createdby);
    echo Form::select('related_tutorial', $tutoriallist, Session::get('tutorialid'), array('class' => 'pull-right uneditable-input', 'style' => 'clear:right;margin:5px;height:30px;'));
}
echo Form::label('submitted_to', "Submitted To", array('class' => 'pull-left', 'style' => 'clear:left;margin:10px;'));
$teacherlist = [$teacher->id => $teacher->first_name . ' ' . $teacher->last_name];
echo Form::select('submitted_to', $teacherlist, $teacher->id, array('class' => 'pull-right disabled uneditable-input', 'style' => 'clear:right;margin:5px;height:30px;'));
echo Form::label('subject', 'Subject', array('class' => 'pull-left', 'style' => 'clear:left;margin:10px;'));
$subjectid = $tutorial->subjectid;
$subject = Subject::findOrFail($subjectid);
$subjectlist = [$subjectid => $subject->subjectname];
echo Form::select('subject', $subjectlist, $subjectid, array('class' => 'pull-right disabled uneditable-input', 'style' => 'clear:right;margin:5px;height:30px;'));
echo Form::label('examid', "Exam ID", array('class' => 'pull-left', 'style' => 'margin:20px;clear:left;'));
echo Form::text('examid', $examid, array('style' => 'clear:right;margin:10px;', 'class' => 'pull-right disabled', 'disabled'));
echo "</div></div></div>";
echo "<h3>Questions</h3>";
echo "<div id='exams'>";
$hash = $exam->hash;
$examdata_encoded = File::get(app_path() . '/files/exam-' . $examid . '/' . $hash . '.json');
Session::put('questiondata_key', 1);
$examdata = json_decode($examdata_encoded);
$examdata = objectToArray($examdata);
foreach ($examdata['questiondata']['questions'] as $question) {
    $qc = Session::get('questiondata_key', 1);
    echo '<div class="container-fluid">
開發者ID:eufelipemartins,項目名稱:edlara,代碼行數:31,代碼來源:view.blade.php

示例3: destroy

 /**
  * Elimina el objetivo especificado de la base de datos
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($admin, $id)
 {
     $subject = Subject::findOrFail($id);
     if (Subject::destroy($id)) {
         $this->log_action('Objetivo Eliminado', 'El objetivo "' . $subject->name . '" ha sido eliminado.');
         Session::flash('msj', 'El objetivo ha sido eliminado exitosamente.');
         return Redirect::route('admin.index', ['admin' => $admin]);
     } else {
         Session::flash('msj', 'Hubo un error y el objetivo no pudo ser eliminado.');
         Session::flash('msj_fallido', 'Hubo un error y el objetivo no pudo ser eliminado.');
         return Redirect::route('admin.index', ['admin' => $admin]);
     }
 }
開發者ID:betancourtfran,項目名稱:tep,代碼行數:19,代碼來源:SubjectsController.php


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