<?php
namespace app\components;

use Yii;
use app\models\Resour_course;

class ResourCourseHelper{

	//课程按首字母分组
	public static function ShowCourseGroups($condition=""){
		$msg = [];
		$letterarr = explode(",", Yii::$app->params["en_letters"]);
		if(empty($condition)){
			$condition = "1=1";
		}
		foreach ($letterarr as $oneletter) {
			$msg[$oneletter] = Resour_course::find()->select("id,name,firstletter,spelling")->where($condition ." and firstletter='". $oneletter ."'")->orderby("spelling asc")->all();
		}
		$msg["--"] = Resour_course::find()->select("id,name,firstletter,spelling")->where($condition ." and firstletter=''")->orderby("spelling asc")->all();
		return $msg;
	}
		
}
?>