2017-04-17 1 views
0

내 웹 사이트를 기록하고 Laravel로 이동하고 있지만 어떤 이유로 프로필 페이지로 리디렉션되는 검색 양식을 얻는 방법을 알 수 없습니다.Laravel 5 양식 Submit to View

<form class="navbar-form navbar-right search" role="search" action="/profile/" method="GET"> 
<div class="input-group"> 
<input type="text" class="form-control navbar-player-search" placeholder="Enter IGN here" autocomplete="off" required> 
     <div class="input-group-btn"> 
      <button type="submit" class="btn btn-default"> 
       <i class="glyphicon glyphicon-search"></i> 
      </button> 
     </div> 
    </div> 
</form> 

나는 경로가 이미 나는

Route::get('/profile/{Profile}', '[email protected]'); 

을 example.com/profile/Callahan 갔다 경우 작동하는 설정하지만 똑같은 것을 할 양식이 필요합니다. 기본 laravel 5.4.3으로이 작업을 수행 할 수 있습니까? 아니면 https://laravelcollective.com/docs/5.3/html과 같은 것이 필요합니까?

답변

0

나는 정확히 입력에 포함 된 정보를 이해하지 않지만, 나는이 고려 있습니다 :

사용자 입력에 작성하고 검색을 클릭합니다. 그러면 컨트롤러에서 검색 후 프로필 이름을 가져 와서 프로필로 리디렉션합니다. 그럴까요?

라우팅

Route::get('/profile/{Profile}', '[email protected]'); 
Route::get('/search', '[email protected]'); 
Route::post('/search', '[email protected]'); 

컨트롤러

public function searchForm() { 
    return view('search'); 
} 

public function search(Request $request) { 
    // get the input 
    $inputText = ...; 
    // logic to get the profile name 
    $profileName = ...; 
    return redirect('/profile/'.$profileName); 
} 

보기

:

그렇다면, 당신은 그런 일을해야

<form class="navbar-form navbar-right search" role="search" action="/search" method="POST"> 
<div class="input-group"> 
<input type="text" class="form-control navbar-player-search" placeholder="Enter IGN here" autocomplete="off" required> 
     <div class="input-group-btn"> 
      <button type="submit" class="btn btn-default"> 
       <i class="glyphicon glyphicon-search"></i> 
      </button> 
     </div> 
    </div> 
</form> 

또 다시, 나는 그것이 당신이 정말로 원하는 것인지 알지 못하지만, 그렇지 않다면, 다시 당신을 도우려는 것을 알려주십시오.

+0

공개 함수 searchForm() { return view ('search'); } 블레이드 뷰가 필요합니까? – Callahan

+0

상단의 navbar에 html 검색 바코드가 있습니다. 이전 사이트에서 해당 데이터를 페이지에 게시 한 다음 게시물 데이터가 전송되었는지 확인하고 거기에 리디렉션합니다. – Callahan

+0

블레이드를 사용할 필요가 없습니다. . 파일은 단지 .php 일 수 있으며 정상적으로 작동합니다. 그렇다면이 코드들이 당신에게 효과가 있습니까? –