我试图anINT从这个 URL: myapp.build/courses/anINT(在 中实现CoursesController) 传递到下面$id的Lesson_unitsController函数中。我尝试了很多解决方案,但似乎无法解决问题。
CoursesController 中实现 url 的函数是:
public function show($id)
{
$course = Course::find($id);
return view('courses.show')->with('course', $course);
}
show.blade.php 文件的一部分是:
@if(!Auth::guest())
@if(Auth::user()->id == $course->user_id)
<a href="/courses/{{$course->id}}/edit" class="btn btn-outline-secondary btn-light">Edit Course</a>
<a href="/lesson_units/specificindex" class="btn btn-outline-secondary btn-light">Lesson Units</a>
{!!Form::open(['action'=> ['CoursesController@destroy', $course->id], 'method' => 'POST', 'class' => 'float-right'])!!}
{{Form::hidden('_method', 'DELETE')}}
{{Form::submit('Delete', ['class' => 'btn btn-danger'])}}
{!!Form::close()!!}
@endif
@endif
该Lesson_unitsController功能是:
public function index()
{
$lesson_units = Lesson_unit::orderBy('title','asc')->paginate(10);
return view('lesson_units.index')->with('lesson_units', $lesson_units);
}
public function specificindex($id)
{
$course = Course::find($id);
return view('lesson_units.specificindex')->with('lesson_units', $course->lesson_units);
}
web.php 中的路由是:
Route::resource('courses', 'CoursesController');
Route::resource('lesson_units', 'Lesson_unitsController');
Route::get('/courses/{id}', 'Lesson_unitsController@specificIndex');
我想的是,链接,当Lesson Units点击了网页上,在idurl中传递给specificindex该函数Lesson_unitsController。现在,我只得到一个空白页。我究竟做错了什么?
杨__羊羊