vendredi 24 mars 2017

Get the latest record of a particular id in a table

    ScholarCard
    scholar_card_id         grade       scholar_id
    1                       grade-1         1
    2                       grade-1         2
    3                       grade-2         1
    4                       grade-2         2
    5                       grade-3         1

$scholar_cards = ScholarCard::orderBy('scholar_card_id','DESC')->get();

I have a table for a card of grades and i want to display the latest created card. Like for example for scholar_id 1,there are three 1 on the column.How do you display only the scholar_id 1 with the latest or last creation.This table has only few record for simplicity.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire