怎么传递整篇文章呢?
我想在文章的详情页里增加一个按钮,因为我要在下一个页面里来处理这篇文章的一个字段,这个字段里是json的数据,所以我在blade里写了
<div class="container-fiuled bg-white mt-4 d-flex flex-column pb-3">
<div class="test-detail-title w-75 pt-4 pb-2 m-auto text-center">
<h3 class="pt-3">{{ $testpsy->title }}</h3>
</div>
<div class="test-introduce-img mb-3">
<img src="{{ $testpsy->cover }}" alt="" class="w-100">
</div>
<div class="test-detail-info w-75 m-auto text-center">
<p>{{ $testpsy->description }}</p>
</div>
<div class="start-button text-center">
<a href="{{ route('testpsies.progess', [$testpsy]) }}" class="btn btn-primary w-75 btn-lg">开始测试</a>
</div>
</div>
路由:
Route::get('testpsies/progess/{test}', 'TestPsiesController@testProgrss')->name('testpsies.progess');
controller
public function testProgrss(TestPsy $testpsy)
{
dd($testpsy->id);
if($testpsy->price) {
return view('mobile.test_psies.progress', compact('testpsy'));
}
else {
return view('mobile.test_psies.progress_free', compact('testpsy'));
}
}
但是这个dd出来的数据是null,怎么能得到对应的内容呢?
看这个,像是隐形绑定路由的用法不对。隐形绑定。
有个要求,url 中传的是 id ,类型提示的变量名和路由中的参数要相同。你试一下。