Retrieving A Portion Of The Input Data
If you need to retrieve a subset of the input data, you may use the only and except methods. Both of these methods accept a single array or a dynamic list of arguments:
$input = $request->only(['username', 'password']); $input = $request->only('username', 'password'); $input = $request->except(['credit_card']); $input = $request->except('credit_card');
onlyとexpectの違いは?
Determining If An Input Value Is Present
You should use the has method to determine if a value is present on the request. The has method returns true if the value is present on the request:
ここらへんは分かり易い。
if ($request->has('name')) { // } if ($request->has(['name', 'email'])) { // } if ($request->filled('name')) { // }