Here is the table
table: StudentHistory
id | date | name | grade | subject
---- | ------ |------ |--------|------
1 | 5/1/2017 |Mark | a | science
2 | 7/1/2016 |Earl | c | english
3 | 2/1/2015 |John | a | english
4 | 6/1/2016 |Mike | c | science
5 | 4/1/2016 |Matt | e | english
6 | 2/1/2017 |Mark | d | science
7 | 3/1/2016 |Earl | a | english
8 | 7/1/2015 |John | d | english
9 | 8/1/2016 |Mike | c | science
What I want to happen is to populate the latest grades ONLY in English for students who have one. It should show like this
7/1/2016 Earl c
7/1/2015 John d
4/1/2016 Matt e
I got this but it doesn't give the latest based on
$englishgrades = StudentHistory::('date', 'name', 'grade')
->where('subject', 'english')
->groupBy('name')
->get();
Please help