2015-01-23 1 views
0

일반적인 질문이 있습니다.Laravel의 데이터베이스 컬럼 업데이트/게시

나는 데이터베이스에서 결과를 반환하는 검색 양식을 larvel에 가지고 있습니다. 이들의

나는 가격 == 0

경우 내가 '가격을 입력하고 아무튼, 즉 내 이전 검색 결과없이 검색 페이지로 돌아 제출할 때 내 문제가 무엇인지 가격을 입력하는 입력 필드가 t는 동일한 결과 페이지 새로 업데이트 등 필드 뷰

형태를 새로

{{ Form::open(['action' => 'price_input'])->with($gyms) }} 
           {{ Form::text('enter_price', null, ['class' =>  'form-control', 'size' => '50', 'id' => 'enter_price', 'autocomplete' => 'on', 'runat' => 'server', 'required' => 'required', 'placeholder' => 'enter price!', 'style' => 'margin-bottom: 0px!important;']) }} 
          {{ Form::submit('Search', ['class' => 'btn btn- primary', 'style' => 'margin-left: 10px;']) }} 
         {{ Form::close() }} 

Route::post('/', [ //not used yet 
'as' => 'price_input', 
'uses' => '[email protected]' 
]); 
,174,

모델

public function priceUpdate($gyms) 
{ 

    if (Input::has('enter_price')) 
    { 

    $price = Input::get('enter_price'); 
    Gym::updatePrice($price); 

    return Redirect::back()->withInput(); 

    } 


    Session::get('gyms'); 

    return Redirect::to('pages.home') ->with('gyms', $gym); 



} 

이 잘 작동으로 모델을 귀찮게하지.

아이디어가 있으십니까? 답변에 대한

덕분에,

나는이

public function priceUpdate($gyms) 
{ 



    if (Input::has('enter_price')) 
    { 

    $price = Input::get('enter_price'); 
    Gym::updatePrice($price); 


    $gyms = Session::get('gyms'); 
    return Redirect::to('pages.home') ->with('gyms', $gyms); 

    } 




    $gyms = Session::get('gyms'); 
    return Redirect::to('pages.home') ->with('gyms', $gyms); 
} 

내 컨트롤러를 변경하지만 난 그것을 실행할 때 나는 이 PagesController에 대한 인수 1 누락 :: priceUpdate() 을 $ 체육관에 도착 메서드에 전달됩니다.

내가 떠나가는 $ gyms를 꺼내지 만 여전히 세션으로 전달되는지 여부는 확실하지 않습니다. 미안하지만 초보자입니다.

는 orignally 내가 돌아

return View::make('pages.home')->with($data); 

그와

return View::make('pages.home')->with($data); 

의 차이점은 무엇입니까를 운영하는 검색 상자를했다 나는 그것을 더 검색과 검색 페이지로 돌아갑니다 위의 라인을 수행 할 때 옵션을 업데이트하기 전에 양식, 아이디어?

답변

0

현재 기존 세션을 검색하고 아무 것도하지 않고 있습니다. 당신은 할 필요가 :

$gyms = Session::get('gyms'); 
return Redirect::to('pages.home') ->with('gyms', $gyms); 

또는

return Redirect::to('pages.home')->with('gyms', Session::get('gyms')); 

이 그럼 당신은 $gyms로보기에서 체육관에 액세스 할 수 있습니다. 또는 Session::get('gyms')에 액세스 할 수 있습니다. 또한 여기에 붙여 넣은 방법인지 확실하지 않지만 ->with 앞에 불필요한 공백이 있습니다. 문제의 일부가 아닌지 확인하고 싶었습니다.

관련 문제