Mysql
 sql >> Database >  >> RDS >> Mysql

Ordina per tabella pivot creata_at in Laravel

Ricevi i corsi dallo studente:

$student = Student::where('user_id', auth()->id())->first();
$courses = $student->courses()->orderByDesc('course_student.created_at')->get();