本文整理汇总了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();
}
示例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">
示例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]);
}
}