gpt4 book ai didi

php - "Type error: Too few arguments to function App\Http\Controllers\FrontController::detail(), 0 passed and exactly 1 expected"

转载 作者:行者123 更新时间:2023-11-29 10:27:43 25 4
gpt4 key购买 nike

我想将 Shirts 中的数据传递给详细信息,以了解 Shirts 中产品的详细信息。怎么做?我这里有一些错误 Error's Message

这是我的 WebView web View

FrontController.php

 class FrontController extends Controller
{
public function index()
{
$shirts=Product::all();
return view('front.home', compact('shirts'));
}
public function shirts()
{
$shirts=Product::all();
return view('front.shirts', compact('shirts'));
}
public function detail($id)
{
return view('front.shirt', ['detail' => Product::findOrFail($id)]);

}

路线Web.php

Route::get('/', 'FrontController@index')->name('home');
Route::get('/shirts', 'FrontController@shirts')->name('shirts');
Route::get('/detail', 'FrontController@detail')->name('detail');

衬衫.blade.php

<a href="{{route('detail', $shirt->id)}}">

最佳答案

你在 route 缺少参数('detail')编辑为:

Route::get('/detail/{id}', 'FrontController@detail')->name('detail');

然后再试一次。希望有帮助:D

关于php - "Type error: Too few arguments to function App\Http\Controllers\FrontController::detail(), 0 passed and exactly 1 expected",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47973366/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com