need print column data in my laravel app. My controller is TaskController.php
public function index()
{
$tasks = Task::all();
return view('tasks.index')->with('tasks', $tasks);
}
index.blade.php file is
@if(isset($tasks))
@foreach ($tasks as $task)
<h1>{{ $task->task_name }}</h1>
@endforeach
@endif
I am going include this index view file in show.blade.php file as following
@include('tasks.index')
but unable to print table data no any errors occurred. how can I print task_name in show view file?