TasksController: 

 public function index() { $tasks = Task::all(); return view('tasks.index', ['tasks' => $tasks] ); } 

 index.blade.php: 

 @foreach($tasks as $task) <tr> <td>{{ $task->id }}</td> <td>{{ $task->subject_id }}</td> <!-- subject_id нужно заменить на subject из другой таблицы --> <td>{{ $task->text }}</td> </tr> @endforeach 

This table structure: enter image description here

How, instead of $task->subject_id display поле subject from the subjects table?

    1 answer 1

    If you have registered the relationship of these models to get this list, you can as follows:

     $result = Task::with('subjects')->get(); 

    Well, or you can do with standard JOIN