Reputation: 5
I have two tables: one for student and one for trades , i need to make a query to match the id with id_student in trades table kowing that id_student is foreign key to student table which has the id column as a primary key. i get nothing from the following code in the trades controller.
$trades = new trades();
$trades = students::orderBy('created_at','desc')->where('id_student', '=', auth()->id_student())
->with(['trades'])
->first();
Upvotes: 0
Views: 35
Reputation: 9303
Use auth()->user()->id_student
not auth()->id_student()
:
$trades = Students::orderBy('created_at','desc')
->where('id_student', auth()->user()->id_student)
->with(['trades'])
->first();
Upvotes: 1