29.07.2016 Views

laravel-5

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

HTTP Requests 87<br />

.<br />

1 $input = $request->input('products.0.name');<br />

Determining If An Input Value Is Present<br />

To determine if a value is present on the request, you may use the has method. The has method<br />

returns true if the value is present and is not an empty string:<br />

.<br />

1 if ($request->has('name')) {<br />

2 //<br />

3 }<br />

Retrieving All Input Data<br />

You may also retrieve all of the input data as an array using the all method:<br />

.<br />

1 $input = $request->all();<br />

Retrieving A Portion Of The Input Data<br />

If you need to retrieve a sub-set of the input data, you may use the only and except methods. Both<br />

of these methods accept a single array as their only argument:<br />

.<br />

1 $input = $request->only('username', 'password');<br />

2<br />

3 $input = $request->except('credit_card');<br />

Old Input<br />

Laravel allows you to keep input from one request during the next request. This feature is particularly<br />

useful for re-populating forms after detecting validation errors. However, if you are using Laravel’s<br />

included validation services, it is unlikely you will need to manually use these methods, as some of<br />

Laravel’s built-in validation facilities will call them automatically.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!