Answer the question
In order to leave comments, you need to log in
How to check HTTP status?
There is an implementation of the method for creating an entry in the database, I need to check it. How to implement it, I can not figure it out yet. I need to execute the else block in case the entry is not created.
public function store(Request $request)
{
$idle = new Idle;
$idle->fill($request->idle)->save();
if (201) [$status = "OK", $message = "Запись создана"];
else [$status = "Error", $message = "Запись не создана"];
return response()->json([
"status" => $status,
"message" => $message,
], 201);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question