that Session element/value is deleted, and can’t be retrieved again. This is exactly what is happening in with() method – its purpose is to add an error message or some input data only for that particular red
1// For a route with the following URI: /profile/{id} 2 3return redirect()->route('profile', [$user]);If you would like to customize the value that is placed in the route parameter, you can specify the column in the route parameter definition (/profile/{id:slug}) or you can ...
1// For a route with the following URI: /profile/{id} 2 3return redirect()->route('profile', [$user]);If you would like to customize the value that is placed in the route parameter, you can specify the column in the route parameter definition (/profile/{id:slug}) or you can ...
with()方法允许我们将数据从控制器传递到视图。这个方法接受两个参数。第一个参数是将在视图中创建的变量的名称。第二个参数将是该变量的值。 总结一下,我们已经查询了数据库中的所有用户,并将它们作为User对象数组传递给了视图。由于users是with()方法的第一个参数,所以User对象数组将在视图中作为变量$users可用。
4.生成重定向的响应:重定向响应是一个特殊的响应,只是在响应报文首部中包含了Location重定向字段,Laravel中的RedirectResponse类是在Symfony框架的RedirectResponse类的基础上加入了session一次性数据、自定义首部信息等功能 https://github.com/zhangyue0503/laravel5.4cn ...
// 控制器publicfunctiontest2(Request $request,$id){var_dump($request===\request());// bool(true)return'test2: '.$id.', '.$request->input('name','').', '.\request()->input('sex','');}// 路由Route::get('test/test2/{id}','App\Http\Controllers\TestController@test2');// ht...
pages|max:255','body'=>'required',]);$page=newPage;$page->title=Input::get('title');$page->body=Input::get('body');$page->user_id=1;//Auth::user()->id;if($page->save()){returnRedirect::to('admin');}else{returnRedirect::back()->withInput()->withErrors('保存失败!');}...
<input type="radio" name="evaluate" class="evaluate" value=10> 1 <input type="radio" name="evaluate" class="evaluate" value=15> 1.5 <input type="radio" name="evaluate" class="evaluate" value=20> 2 <input type="radio" name="evaluate" class="evaluate" value=25> 2.5 ...
Route::post('recipes', function (Illuminate\Http\Request$request) {$validator=Validator::make($request->all(), ['title'=>'required|unique:recipes|max:125','body'=>'required']);if($validator->fails()) {returnredirect('recipes/create') ...
{ User::create(array('name'=> Input::get('name'),'email'=> Input::get('email'),'password'=> Hash::make(Input::get('password')) ));returnRedirect::to('/')->with('message','Thanks for registering!'); }else{returnRedirect::to('/')->withErrors($validator->getMessages()); }...