return (empty($error)) ?
[ 'data' => $data,
'status' => 'success',
'message' => 'Done'
]
:
[ 'data' => $errors,
'status' => 'error',
'message' => $message
];
return (empty($error)) ?[
'data' => $data,
'status' => 'success',
'message' => 'Done'
] : [
'data' => $errors,
'status' => 'error',
'message' => $message
];
if (!empty($errors)) {
return [
'data' => $errors,
'status' => 'error',
'message' => $message,
];
}
return [
'data' => $data,
'status' => 'success',
'message' => 'Done',
];
$status = 'success';
$message = 'Done';
// ...
if (!empty($errors)) {
$data = $errors;
$status = 'error';
}
return [
'data' => $data,
'status' => $status,
'message' => $message,
];
$response = [
'data' => $data,
'status' => 'success',
'message' => 'Done'
];
if (!empty($error)) {
// можно через array_merge еще написать
$response = [
'data' => $errors,
'status' => 'error',
'message' => $message,
];
}
return $response;