I have a list of courses and in each course there is a buttonthat allows me to view all subjects of that particular course.
First, I used this command so laravel already know what the parent element is:
php artisan make:controller CourseSubjectController --model=Subject --parent=Course
In the course index.php file I have the button that should allow me to view all the subjects for that particular:
<td><a class="btn btn-success" href="{{route('departments.course.subjects.index', [$course->department->id, $course->id])}}">Subjects</a></td>
Apparently the url is correct:
The controller looks like this:
public function index(Course $course)
{
return $course->subjects;
}
When I visit the link I encounter this error:
"Type error: Argument 1 passed to App\Http\Controllers\CourseSubjectController::index() must be an instance of App\Course, string given"
How can I view the subjects of the course?
Thanks in advance