Skip to content
Advertisement

Sort By date in hasMany relation first record for Laravel project [closed]

I have a courses table and every course has many sessions,

So I need to sort courses by the first session of the course date for Laravel Project.

Advertisement

Answer

this way you can set a method in Course model to get the oldest Session model(which means first session):

JavaScript

and then you may simply query your course model by adding constraints on that method :

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement