2017-12-26 19 views
0

Shirts의 데이터를 세부 정보로 전달하고 제품의 세부 정보를 알고 싶습니다. 셔츠. 그렇게하는 방법? 여기 Error's Message"유형 오류 : App Http Controllers FrontController :: detail() 함수의 인수가 너무 적습니다. 0이 전달되고 정확히 1이 필요합니다."

일부 오류이 내 웹보기를 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('/', '[email protected]')->name('home'); 
Route::get('/shirts', '[email protected]')->name('shirts'); 
Route::get('/detail', '[email protected]')->name('detail'); 

Shirts.blade.php

난 당신이 또한 ID 매개 변수를 줄 필요가 경로에서 생각 (210)
<a href="{{route('detail', $shirt->id)}}"> 
+0

댓글이 확장 된 논의하지 않습니다; 이 대화는 [채팅으로 이동되었습니다] (http://chat.stackoverflow.com/rooms/161966/discussion-on-question-by-yudha-patria-type-error-to-few-arguments-to-functio) . –

답변

-1

,

Route::get('/detail/{id}', '[email protected]')->name('detail'); 
+0

내가 이것을 줄 때 나는 이런 오류가있다 .... "[Route : detail] [URI : detail/{$ id}]에 대한 필수 매개 변수가 누락되었습니다. (보기 : C : \ xampp \ htdocs \ ecom \ resources \ views \ front \ home.blade.php) " –

+0

보기에서 다음과 같이 시도하십시오. Dhanesh

+0

같은 오류 .."[Route : detail] [URI : detail/{$ id}]에 대한 필수 매개 변수가 없습니다 (보기 : C : \ xampp \ htdocs \ ecom \ resources \ views \ front \ home.blade .php) " –

0

먼저 변경해야하는이 세 가지가는이

Route::get('/detail/{$id}', '[email protected]')->name('detail'); 
같아야 경로 파일 입니다

여기에서 컨트롤러에 전달하는 매개 변수 $ id가 표시됩니다.

및 뷰에 대한

내가 거기에 코드 경로에서 볼 수에 따라 내가 그것을 그것이 도움이되기를 바랍니다 문제를 해결할 수 있다고 생각이

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

처럼되고있다

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

입니다 너

0

경로가 누락 된 인수 ('detail') 편집 대상 :

Route::get('/detail/{id}', '[email protected]')->name('detail'); 

그리고 again.Hope이 도움을보십시오 : D