Laravel controller to update appointment requests My question/refactor is similar to what is found here:
Laravel controller for form validation skinny

However, I feel that the answer is for 5.0 and not 5.2. This question does not pertain only to one controller but considering that I am making a RESTful API I believe 1 example is sufficient so I can propagate this:

class UpdateAppointmentRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return false;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'id' =&gt; 'required|integer',
            'user_id' =&gt; 'required|integer',
            'status' =&gt; 'integer',
            'note' =&gt; 'alpha'
        ];
    }
}

public function update(UpdateAppointmentRequest $request)
{
    $appointment = $this-&gt;appointment-&gt;find($request-&gt;get('id'));
    if ($appointment === null) {
        return $this-&gt;notFound('Appointment Not Found');
    }
    if($request-&gt;has('user_id') === true) {
        $appointment-&gt;user_id = $request-&gt;get('user_id');
    }
    if($request-&gt;has('status') === true) {
        $appointment-&gt;status = $request-&gt;get('status');
    }        
    if($request-&gt;has('note') === true) {
        $appointment-&gt;note = $request-&gt;get('note');
    }  
    try {
        return response()-&gt;json(['created' =&gt; $appointment-&gt;save()]);
    } catch(\PDOException $e) {
        return $this-&gt;internalIssues($e-&gt;getMessage());
    }
}


My issue is the if statements. Now considering that only 2 items from the validation are required and the rest are not - I have to validate if the present of the variable is there in order to update. It works well, but it will eventually make controllers very bloated (depending on which restful resources might have more parameters).

Does anyone know of a better way to refactor this within Laravel 5.2+?
public function update(UpdateAppointmentRequest $request)
{
    try {
        $data = array_filter($request-&gt;only(['user_id','status','note']));
        $appointment = $this-&gt;appointment-&gt;findOrFail($request-&gt;input('id'));
        $result = $appointment-&gt;update($data);
        return response()-&gt;json(['created' =&gt; $result]);
    } catch(\PDOException $e) {
        return $this-&gt;internalIssues($e-&gt;getMessage());
    }
}


What is wrong with this simple solution? If request does not have a field, say user_id, the only would not return that. And if there is an error while updating, the catch would catch that and return error. Why all those manual checking?