So I'm working on this project and I'm not sure which is the better practice and if it does affect performance
So i have 2 database tables
1: Students This table has id , Name , Teacher_id , date
2: Teachers This table has id , Name , date
My goal here is to display all students and get the name of the teachers. Here are both methods that I have.
Method 1
Call from my Model
public static function GetTeacher($id){
return Teacher::where('id',$id)->first();
}
And in my controller
Teacher::GetTeacher($student->teacher_id)->name;
Method 2
Do everything in the model and do a left joint on both tables?
So the main question is which method is better, or is there a better way of doing this. If i can get an article to read on it would be nice.
Thanks.