public function actionShow($id)
 {
     $program = ProgramRecord::findOne($id);
     $courses = CourseRecord::find()->where(['program_id' => $id])->all();
     $course_ids = ArrayHelper::getColumn($courses, 'id');
     $topics = TopicRecord::find()->where(['course_id' => $course_ids])->all();
     $topic_ids = ArrayHelper::getColumn($topics, 'id');
     $program_videos = ContentRecord::find()->where(['topic_id' => $topic_ids, 'type' => 'video'])->all();
     $program_pdf = ContentRecord::find()->where(['topic_id' => $topic_ids, 'type' => 'pdf'])->all();
     $program_img = ContentRecord::find()->where(['topic_id' => $topic_ids, 'type' => 'img'])->all();
     return $this->render('show', ['model_videos' => $program_videos, 'model_pdf' => $program_pdf, 'model_img' => $program_img, 'id' => $id, 'program' => $program]);
 }
 public function actionIndex()
 {
     $user_id = \Yii::$app->user->identity->getId();
     //echo \Yii::$app->user->identity->getId();
     $followed_programs = FollowerProgram::find()->where(['user_id' => $user_id])->all();
     $followed_users = FollowerUsertoUser::find()->where(['follower_user_id' => $user_id])->all();
     $followed_users_ids = ArrayHelper::getColumn($followed_users, 'followed_user_id');
     $followed_programs_ids = ArrayHelper::getColumn($followed_programs, 'program_id');
     $courses = CourseRecord::find()->where(['program_id' => $followed_programs_ids])->all();
     $course_ids = ArrayHelper::getColumn($courses, 'id');
     $topics = TopicRecord::find()->where(['course_id' => $course_ids])->all();
     $topics_ids = ArrayHelper::getColumn($topics, 'id');
     $query = ContentRecord::find()->where(['topic_id' => $topics_ids])->orWhere(['uploadedBy' => $followed_users_ids])->orderBy('id DESC');
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count()]);
     $models = $query->offset($pages->offset)->limit($pages->limit)->all();
     $arr = $this->suggestionForContentsOnTheBasisOfUserLikesAndDislikes();
     if (empty($models)) {
         $models = $this->findSuggestions();
     }
     return $this->render('index', ['models' => $models, 'pages' => $pages, 'arr' => $arr]);
 }
示例#3
0
<?php 
use yii\helpers\Html;
$program = \common\models\program\ProgramRecord::findOne($program_id)->name;
?>
<div class="card-panel horizontal-listing no-padding search-class">
    <div class="container-fluid">
        <h4 class="black-text"><?php 
echo $program;
?>
<i class="material-icons"></i></h4>
        <hr>
        <?php 
foreach ($models as $model) {
    $topics = \common\models\topic\TopicRecord::find()->where(['course_id' => $model->id]);
    ?>
            <a>
                <div class="row hoverable">
                    <div class="col-sm-4">
                        <img src="http://mdbootstrap.com/images/reg/reg%20(54).jpg" class="img-responsive z-depth-2">
                    </div>
                    <div class="col-sm-8">
                        <?php 
    $link_course = '<h5 class="title">' . $model->name . '</h5>';
    echo Html::a($link_course, ['/topic/index', 'course_id' => $model->id, 'university' => $university, 'faculty' => $faculty, 'program' => $program]);
    ?>
                        <ul class="list-inline item-details">
                            <li><i class="fa fa-clock-o"> 05/10/2015 | </i></li>
                            <li><a>Topics <?php 
    echo $topics->count();
    ?>
 public function actionTopics($id)
 {
     $first = 1;
     $count = TopicRecord::find()->where(['course_id' => $id])->count();
     $topics = TopicRecord::find()->where(['course_id' => $id])->all();
     if ($count > 0) {
         echo "<option value='" . $first . "'>" . 'select' . "</option>";
         foreach ($topics as $topic) {
             echo "<option  value='" . $topic->id . "'>" . $topic->name . "</option>";
         }
     } else {
         echo "<option>-</option>";
     }
 }