如何使用可变laravel 5.2重定向视图?

时间:2016-12-28 08:56:48

标签: php laravel encryption laravel-5.2

我已经加密了url。如果我没有加密,那么一切正常。现在我想要加密的URL并将$applicantData变量发送到视图(确认刀片)。但是如果我添加加密那么它的url会完全改变但是我无法发送$applicantData变量来查看我的错误。我怎样才能解决这个问题?我正在使用laravel 5.2。

路线:

Route::group(['prefix' => 'career'], function () {
    Route::get('/', ['as' => 'careerHome' , 'uses' => 'ApplicantController@index']);
    Route::get('apply', ['as' => 'addApplicant', 'uses' => 'ApplicantController@create']);
    Route::post('save', ['as' => 'saveApplicant', 'uses' => 'ApplicantController@store']);
    Route::get('confirmation/{id}', ['as' => 'confirmationMsg', 'uses' => 'ApplicantController@show']);
});

ApplicantController:

$id = $applicant->id;
$applicantData = Applicant::whereId($id)->first();
\Session::flash('flash_message','Application has been successfully submitted.');
return redirect()->to('career/confirmation/'.encrypt($id))->withErrors(compact("applicantData"));

1 个答案:

答案 0 :(得分:1)

使用Redirect::to进行重定向,withInput()->withErrors(['msg' => "some error happens"]);就像这样:

return Redirect::to('career/confirmation/'.encrypt($id))->withInput()->withErrors(compact("applicantData"));

并在你的刀片中显示如下错误:

      <ul class="errors">
@foreach ($errors->all() as $message)
        <li>{{ $message }}</li>
@endforeach
      </ul>