【发布时间】:2017-05-18 17:19:41
【问题描述】:
我想问你是否可以帮助我解决我在新安装的 Laravel 5.4 中遇到的错误。这是我的刀片模板
home.blade.php
@extends('layouts.app') @section('content') <div class="container">
<div class="row">
{{ App\StudentHistory::select(['date', 'student_id', 'grade'])
->where('subject', 'English')
->groupBy('student_id')
->orderBy('date','desc')
->first()
->get()}}
</div>@endsection
让我知道你们还需要什么,我会按你的要求更新
【问题讨论】:
-
为什么要在视图层进行数据库查询?
-
->first()上没有->get() -
@Maerlyn,我实际上可以从控制器中做到这一点。它应该是双向的,对吧?亚历克斯,你的意思是说我不能让两者使用相同的语法?