So I have this for each "project"
@foreach ($projects as $project) <tr> <td>{{$project->proj_id}}</td> <td>{{$project->proj_title}}</td> <td>{{$project->proj_desc}}</td> <td>{{$client->find($project->client_id)->client_name}}</td> <td>{{$project->user->name}}</td> <td>{{$project->created_at}}</td> @if (Auth::user()->role=='admin') <td> <div class="dropdown"> <button class="btn btn-danger dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Action</button> <div class="dropdown-menu" aria-labelledby="dropdownMenuButton"> <a class="dropdown-item" href="{{route('projects.edit',$project)}}">Edit</a> <form method="POST" action="{{route('projects.destroy',$project)}}" onsubmit="return confirm('Are you sure you want to delete this?')"> @method('DELETE') @csrf <button class="dropdown-item" type="submit">Delete</button> @endif ------------> <a class="dropdown-item" href="{{route('projects.tasks',$project)}}">tasks</a> </form> </div> </div> </td> </tr> @endforeach Where I need help is in the line <a class="dropdown-item" href="{{route('projects.tasks',$project)}}">tasks</a>
That route goes to my controller:
Route::get('/projects/tasks', ['as' => 'projects.tasks', 'uses' => 'ProjectController@seeTasks']); I need to pass that controller the id of the project in which I clicked so I can display all the tasks linked to it. I already have all relations done I just need help with this part. I don't know what I need to do to accomplish this.
This is the function I have for now in my controller:
public function seeTasks(Project $project){ return $project; } It returns an empty array []
Thanks in advance