Its my Db structure I have a student table as
students
+-------+--------+----------+
|id | name | group_id |
+-------+--------+----------+
|1 | ali | 1 |
|2 | ahmad | 2 |
+-------+--------+----------+
groups
+------+-------------+
|id | group_name |
+------+-------------+
|1 | A |
|2 | B |
+------+-------------+
Now I have to show Name from student table and group_name from Groups
StudentController
{
$students = Student::orderBy('id', 'desc')->get();
return view('student.index')->with(compact('students'));
}
My View
@foreach($students as $student)
<td>{{ $student->name }}</td>
<td {{ $student->group_name }} </td>
Please help me to retrieve record from both tables I try with different methods but failed