I have generated an API using Laravel.
In my controller I have the following function for the update :
public function update(Request $request, $id)
{
$data = Link::find($id);
$data->title = is_null($request->title) ? $data->title : $request->title;
$data->save();
}
What is basically does it that it verifies if the received input is null, it returns the default value, else it requests the new one.
The problem here is that when I update the input with an empty value such as 5 space characters, the input in the database doesn't receive the new value because it considers the space as null.
I have in mind maybe a solution like checking the number of characters in the received input. Like if the received string is less than 1 instead of is_null then return the default value . Is it right ?
exceptproperty, you can define which routes you want to have excluded.