本文整理汇总了PHP中app\Course::first方法的典型用法代码示例。如果您正苦于以下问题:PHP Course::first方法的具体用法?PHP Course::first怎么用?PHP Course::first使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Course
的用法示例。
在下文中一共展示了Course::first方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tryEnroll
public function tryEnroll($sid, $class)
{
//Get Cid
$cid = Course::first()->getCid($class);
// Check if Student has taken the class.
$x = ClassesTaken::where('id', $sid)->where('cid', '=', $cid)->first();
if ($x) {
return array("You have already taken this course.");
//return false;
} else {
$list = Course::where('cid', '=', $cid)->first()->requisites;
//if list is empty, return null;
//if(!($list))
//return array();
$results = array();
foreach ($list as $row) {
//IF Prerequisite OR Prerequisite, check both
if ($row->ORprid) {
$get1 = ClassesTaken::find($sid)->where('cid', '=', $row->prid)->first();
$get2 = ClassesTaken::find($sid)->where('cid', '=', $row->ORprid)->first();
//If student hasn't taken both courses
if (!($get1 || $get2)) {
$x = CourseInfo::find($row->prid)->subjectNumber();
$y = CourseInfo::find($row->ORprid)->subjectNumber();
$result = "You are missing " . $x . " or " . $y . " prerequisites.";
array_push($results, $result);
//return false;
}
} elseif ($row->prid) {
$hit = ClassesTaken::find($sid)->where('cid', '=', $row->prid)->first();
if (!$hit) {
$y = CourseInfo::find($row->prid)->subjectNumber();
$result = "You are missing " . $y . " prerequisite.";
array_push($results, $result);
//return false;
}
}
}
return $results;
//return true;
}
}