本文整理汇总了PHP中app\models\Course::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Course::find方法的具体用法?PHP Course::find怎么用?PHP Course::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Course
的用法示例。
在下文中一共展示了Course::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: optional
<?php
use kartik\tree\TreeView;
use app\models\Course;
use yii\helpers\html;
$this->title = Yii::t('app', 'Course Manage');
echo TreeView::widget([
// single query fetch to render the tree
// use the Product model you have in the previous step
'query' => Course::find()->addOrderBy('root, lft'),
'headingOptions' => ['label' => Yii::t('app', 'Contents')],
'fontAwesome' => false, // optional
'isAdmin' => true, // optional (toggle to enable admin mode)
'displayValue' => 1, // initial display value
'softDelete' => true, // defaults to true
'cacheSettings' => [
'enableCache' => true // defaults to true
]
]);
示例2: create
/**
* Show the form for creating a new resource.
*
* @param $courseId
* @return \Illuminate\Http\Response
*/
public function create($courseId)
{
$userId = Auth::user()->id;
$tests = Test::where('user_id', '=', $userId)->get();
$course = Course::find($courseId);
return view('course.lesson.create', ['course' => $course, 'tests' => $tests]);
}
示例3: getInstitute
public function getInstitute()
{
if ($this->course_id != NULL) {
$institute_id = Course::find()->select(['institute_id'])->where(['id' => $this->course_id])->one()->institute_id;
$institute = Institute::findOne(['id' => $institute_id]);
return $institute;
}
}
示例4: courseDropDown
public static function courseDropDown()
{
$courses = Course::find()->all();
//$courses = Course::courseDropDown();
//$courseList = ArrayHelper::map($courses, 'id', 'courseName');
foreach ((array) $courses as $course) {
echo "<option value='" . $course->id . "'>" . $course->courseName . "</option>";
}
}
示例5: show
/**
* 显示学生详细成绩单
* @author FuRongxin
* @date 2016-01-25
* @version 2.0
* @param string $kch 8位课程号
* @return \Illuminate\Http\Response 学生成绩单
*/
public function show($kch)
{
// 过程成绩
$detail = Dtscore::detailScore(Auth::user(), $kch)->select('xh', 'xm', 'kcxh', 'kcpt', 'kcxz', 'nd', 'xq', 'kh', 'cj1', 'cj2', 'cj3', 'cj4', 'cj5', 'cj6', 'zpcj', 'kszt', 'tjzt');
// 补考成绩
$makeup = Muscore::makeupScore(Auth::user(), $kch)->select('xh', 'xm', 'kcxh', 'kcpt', 'kcxz', 'nd', 'xq', 'kh', 'cj1', 'cj2', 'cj3', 'cj4', 'cj5', 'cj6', 'zpcj', 'kszt', 'tjzt');
$scores = $detail->union($makeup)->orderBy('nd', 'desc')->orderBy('xq', 'desc')->get();
$ratios = $this->_arrangeScores($scores);
return view('score.show')->withTitle(Course::find($kch)->kcmc . '课程详细成绩单')->withRatios($ratios);
}
示例6: actionView
/**
* Displays a single Course model.
* @param integer $id
* @return mixed
*/
public function actionView()
{
$courseID = $_GET['id'];
$id = \Yii::$app->user->identity->id;
$model = Course::find()->innerJoin("person_course_role", 'course.id = person_course_role.course_id')->where(["person_course_role.person_id" => $id])->andWhere(["person_course_role.role_id" => CourseRoleHelper::EMPLOYEE])->andWhere(["course.id" => $courseID])->one();
if (!$model) {
throw new ForbiddenHttpException("You have no access to this course");
}
return $this->render('view', ['model' => $model]);
}
示例7: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
$course = Course::find($id);
if ($course) {
$message = 'Success.';
return Response()->json(ResponseManager::getResult($course, 10, $message));
} else {
$message = 'Something went wrong. Please try again.';
return Response()->json(ResponseManager::getError('', 10, $message));
}
}
示例8: actionCertification
public function actionCertification()
{
//$searchModel = new CourseSearch();
//$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
//$dataProvider->pagination->pageSize = 0;
$query = Course::find()->where(['category_id' => '5']);
$dataProvider = new ActiveDataProvider(['query' => $query]);
$cat = new Category();
return $this->render('mos', ['dataProvider' => $dataProvider, 'cat' => $cat]);
//return $this->render('mos');
}
示例9: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Course::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'name' => $this->name, 'leerlijn_id' => $this->leerlijn_id]);
$query->andFilterWhere(['like', 'tud_id', $this->tud_id]);
return $dataProvider;
}
示例10: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Course::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['category_id' => $this->category_id, 'price' => $this->price, 'created_dt' => $this->created_dt]);
$query->andFilterWhere(['like', 'course_id', $this->course_id])->andFilterWhere(['like', 'course_name', $this->course_name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'course_detail', $this->course_detail])->andFilterWhere(['like', 'duration', $this->duration])->andFilterWhere(['like', 'f_jan', $this->f_jan])->andFilterWhere(['like', 'f_feb', $this->f_feb])->andFilterWhere(['like', 'f_mar', $this->f_mar])->andFilterWhere(['like', 'f_apr', $this->f_apr])->andFilterWhere(['like', 'f_may', $this->f_may])->andFilterWhere(['like', 'f_jun', $this->f_jun])->andFilterWhere(['like', 'f_july', $this->f_july])->andFilterWhere(['like', 'f_aug', $this->f_aug])->andFilterWhere(['like', 'f_sep', $this->f_sep])->andFilterWhere(['like', 'f_oct', $this->f_oct])->andFilterWhere(['like', 'f_nov', $this->f_nov])->andFilterWhere(['like', 'f_dec', $this->f_dec])->andFilterWhere(['like', 'level', $this->level])->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'photo', $this->photo]);
return $dataProvider;
}
示例11: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Course::find();
$dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => Yii::$app->params['pageSize']]]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'modified_at' => $this->modified_at]);
$query->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description]);
return $dataProvider;
}
示例12: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Course::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->joinWith('crsCt');
$query->andFilterWhere(['crs_id' => $this->crs_id, 'crs_duration' => $this->crs_duration, 'crs_days' => $this->crs_days, 'crs_wkly_hrs' => $this->crs_wkly_hrs, 'crs_active' => $this->crs_active]);
$query->andFilterWhere(['like', 'crs_desc', $this->crs_desc])->andFilterWhere(['like', 'crs_drtn_type', $this->crs_drtn_type])->andFilterWhere(['like', 'crs_disp_id', $this->crs_disp_id])->andFilterWhere(['like', 'course_type.ct_desc', $this->crs_ct_id]);
return $dataProvider;
}
示例13: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Course::find();
$query->joinWith(['institute']);
$dataProvider = new ActiveDataProvider(['query' => $query]);
$dataProvider->sort->attributes['institute'] = ['asc' => ['institute.name' => SORT_ASC], 'desc' => ['institute.name' => SORT_DESC]];
if (!($this->load($params) && $this->validate())) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'institute_id' => $this->institute_id]);
$query->andFilterWhere(['like', 'name', $this->name]);
$query->andFilterWhere(['like', 'institute.name', $this->institute]);
return $dataProvider;
}
示例14: actionDelete
/**
* Deletes an existing CourseType model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
*/
public function actionDelete($id)
{
try {
// $this->findModel($id)->delete();
$ct = $this->findModel($id);
//$crs = $ct->courses;
//$cls = $ct->clsses;
$crs_count = Course::find()->where(['crs_ct_id' => $id])->count();
$cls_count = Clss::find()->where(['clss_ct_id' => $id])->count();
Yii::$app->session->setFlash('message', "You cannot delete this record!");
if ($crs_count == 0 && $cls_count == 0) {
$ct->delete();
// Yii::$app->session->setFlash('success','The car was successfully deleted');
// foreach (Yii::$app->session->getAllFlashes() as $key => $message) {
echo '<div class="alert alert-success">' . 'The car was successfully deleted' . '</div>';
// }
} else {
//header("HTTP/1.0 400 Relation Restriction");
Yii::$app->session->setFlash('message', "You cannot delete this record!");
}
} catch (CDbException $e) {
if ($e->errorInfo[1] == 1451) {
header("HTTP/1.0 400 Relation Restriction");
echo "Your error message.\n";
} else {
throw $e;
}
// } catch (IntegrityException $e) {
// if($e->getCode()===23000){
//You can have nother error handling
// header("HTTP/1.0 400 Relation Restriction");
// }else{
// throw $e;
//}
}
return $this->redirect(['index']);
}
示例15: show
/**
* 显示评教结果
* @author FuRongxin
* @date 2016-03-30
* @version 2.0
* @param \Illuminate\Http\Request $request 评教结果请求
* @param string $kcxh 12位课程序号
* @return \Illuminate\Http\Response 评教结果
*/
public function show(Request $request, $kcxh)
{
$inputs = $request->all();
$table = $inputs['year'] . $inputs['term'] . 't';
$mark = $inputs['year'] . $inputs['term'] . 'Mark';
// 获取评教分值
$data = DB::connection('pgset')->selectOne('SELECT AVG(s_jxtd) AS jxtd, AVG(s_jxnr) AS jxnr, AVG(s_jxff) AS jxff, AVG(s_jxxg) AS jxxg, AVG(s_zhpf) As zhpf FROM "' . $table . '" WHERE c_kcxh = ? and c_jsgh = ? GROUP BY c_kcbh, c_jsgh', [$kcxh, Auth::user()->jsgh]);
$scores = [];
if (count($data)) {
$scores = ['1' => sprintf('%.2f', $data->jxtd), '2' => sprintf('%.2f', $data->jxnr), '3' => sprintf('%.2f', $data->jxff), '4' => sprintf('%.2f', $data->jxxg), 'zhpf' => sprintf('%.2f', $data->zhpf)];
$categories = DB::connection('pgset')->select('SELECT a.zb_id, a.zb_mc, COUNT(*) AS total FROM t_zb_yjzb a, t_zb_ejzb b WHERE a.zb_id = b.zb_id GROUP BY a.zb_id, a.zb_mc ORDER BY a.zb_id');
foreach ($categories as $category) {
$items = DB::connection('pgset')->select('SELECT ejzb_id, ejzb_mc, AVG(s_mark) AS mark FROM "' . $mark . '", t_zb_ejzb WHERE c_xm = CAST(ejzb_id AS TEXT) AND zb_id = ? AND c_kcxh = ? AND c_jsgh = ? GROUP BY ejzb_id, ejzb_mc, c_kcbh, c_jsgh, c_xm ORDER BY ejzb_id', [$category->zb_id, $kcxh, Auth::user()->jsgh]);
$scores['zb'][$category->zb_id] = ['zb_mc' => $category->zb_mc, 'total' => $category->total];
foreach ($items as $item) {
$scores['zb'][$category->zb_id]['ejzb'][] = ['ejzb_id' => $item->ejzb_id, 'ejzb_mc' => $item->ejzb_mc, 'score' => sprintf('%.2f', $item->mark)];
}
}
}
// 获取评教评语
$comments = DB::connection('pgset')->select('SELECT c_yd, c_qd, c_one, c_xh FROM t_zl_xspy a INNER JOIN "' . $table . '" b ON a.c_kcxh = b.c_kcxh WHERE a.c_nd = ? AND a.c_xq = ? AND b.c_jsgh = ? AND b.c_kcxh = ?', [$inputs['year'], $inputs['term'], Auth::user()->jsgh, $kcxh]);
$title = $inputs['year'] . '年度' . Term::find($inputs['term'])->mc . '学期' . $kcxh . Course::find(Helper::getCno($kcxh))->kcmc . '课程';
return view('set.show')->withTitle($title . '评教结果')->withScores($scores)->withComments($comments);
}