本文整理匯總了PHP中app\models\Course::queryCourse方法的典型用法代碼示例。如果您正苦於以下問題:PHP Course::queryCourse方法的具體用法?PHP Course::queryCourse怎麽用?PHP Course::queryCourse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\models\Course
的用法示例。
在下文中一共展示了Course::queryCourse方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionList
public function actionList()
{
$course = Yii::$app->request->get('c');
$difficulty_level = Yii::$app->request->get('is_easy');
// $sort = Yii::$app->request->get('sort');
$newCourseList = [];
//獲取最新的課程列表
$hotCourseList = [];
//獲取最熱的課程列表
$showCategoryList = [];
//該方向下的所有列表
$activeDirection = '';
//點擊的方向
$activeCategoryList = [];
//需要搜索的列表
$activeCategory = '';
//點擊的分類名稱
$activeDifficulty = '';
//點擊的課程程度
if (!empty($course)) {
//如果course在方向列表中,則獲取分類列表;如果在分類列表裏,則
if (in_array($course, Category::$direction)) {
$activeDirection = $course;
//將搜索的方向設為active
$aliasList = Category::directionAliasList();
$directionId = $aliasList[$course];
$showCategoryList = Category::findModelsByDirection($directionId);
//該方向下的所有列表
$activeCategoryList = $showCategoryList;
//需要搜索的列表
} else {
if (in_array($course, Category::aliasList())) {
$directionId = Category::getDirectionByAlias($course)->direction;
//該分類所在的方向ID
$directionAliasFlipList = Category::directionAliasFlipList();
$activeDirection = $directionAliasFlipList[$directionId];
//獲取active方向名稱
$showCategoryList = Category::findModelsByDirection($directionId);
//該方向下的所有列表
$activeCategoryList = Category::findModelByAlias($course);
//隻有一個對象的對象數組
$activeCategory = $course;
//點擊的分類名稱
} else {
$course = '';
}
}
//如果不為空則獲取課程列表
if (!empty($activeCategoryList)) {
foreach ($activeCategoryList as $category) {
$newCourseList[] = Course::queryCourse($category->id, $difficulty_level, 'new');
$hotCourseList[] = Course::queryCourse($category->id, $difficulty_level, 'hot');
}
}
}
//course為空;獲取全部課程列表
if (empty($course)) {
$showCategoryList = Category::findAllModels();
$newCourseList[] = Course::queryCourse('', $difficulty_level, 'new');
$hotCourseList[] = Course::queryCourse('', $difficulty_level, 'hot');
}
if (!empty($difficulty_level)) {
$activeDifficulty = $difficulty_level;
}
return $this->render('list', ['c' => $course, 'is_easy' => $difficulty_level, 'newCourseList' => array_filter($newCourseList), 'hotCourseList' => array_filter($hotCourseList), 'activeDirection' => $activeDirection, 'activeCategory' => $activeCategory, 'showCategoryList' => $showCategoryList, 'activeDifficulty' => $activeDifficulty]);
}