怎么传递整篇文章呢?

我想在文章的详情页里增加一个按钮,因为我要在下一个页面里来处理这篇文章的一个字段,这个字段里是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,怎么能得到对应的内容呢?

《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
讨论数量: 1

看这个,像是隐形绑定路由的用法不对。隐形绑定
有个要求,url 中传的是 id ,类型提示的变量名和路由中的参数要相同。你试一下。

<a href="{{ route('testpsies.progess', [$testpsy->id]) }}"  <----这里传id
Route::get('testpsies/progess/{testpsy}'  <---- 这里改成 testpsy,与控制器中的对应
public function testProgrss(TestPsy $testpsy)  <----- 与上面的路由中的参数名对应
4年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!