Laravel controller to update appointment requests
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?