从查询中获取laravel视图中foreach中的行值

时间:2018-02-15 21:40:55

标签: laravel-5

我必须得到查询newsubject =“”的每一行的主题名称。查询需要4个参数,3个由输入提供。主题将从视图行中获得。我希望能够获得一个具有特定学年和课程的学生的等级

$getProgramme = Input::get('getProgramme');
    $getYear = Input::get('getYear');
    $getTerm = Input::get('getTerm');
    $getLevel = Input::get('getLevel');

    $getResults = DB::table('resultsView')
        ->leftjoin(DB::raw('((SELECT sregNumber1, scorelevel1,term_Desc1,term_Year1, newsubject,prog1,
        CASE WHEN @prevRank = total_score1 THEN @curRank WHEN @prevRank := total_score1 THEN @curRank := @curRank + 1 END AS subject_ranked FROM scorebysubject q,
                          (SELECT @curRank :=0, @prevRank := NULL) r where prog1 ="' . $getProgramme . '" and  `scorelevel1` = "' . $getLevel . '" and term_Desc1 = "' . $getTerm . '"
                          and term_Year1 = "' . $getYear . '" and newsubject =  " " ORDER BY total_score1 Desc) as t3 )'), function ($join) {
            $join->on('sregNumber1', '=', 'regNumber')
                ->on('newsubject', '=', 'subject')
                ->on('term_Desc1', '=', 'termDesc')
                ->on('prog1', '=', 'programmes')
                ->on('term_Year1', '=', 'ternYear');
        })
        ->where('programmes', $getProgramme)
        ->where('ternYear', $getYear)
        ->where('termDesc', $getTerm)
        ->where('level', $getLevel)
        ->get();

这是我的观点

  </tr>
                </thead>

                @foreach ($item->groupBy('groups') as $grouped)
                    <tr>
                        <td>
                        <td>{{$grouped[0]->groups}}</td>
                        </td>
                    </tr>


                    @foreach ($grouped as $row)
                    <tr>



                        <td>{{ isset($row->subject) ? $row->subject : '' }}</td>
                        <td>{{ $row->exams30 }}</td>
                        <td>{{ $row->exams70 }}</td>
                        <td>{{ $row->exams100 }}</td>
                        <td>{{ $row->subject_ranked }}</td>

                        <td>{{ $row->grade }}</td>
                        <td>{{ $row->remarks }}</td>
                        @endforeach

                    </tr>
                    @endforeach

                @endforeach

0 个答案:

没有答案