Answer the question
In order to leave comments, you need to log in
Why is redirect() not returning a page?
Laravel 5.7
In a controller, when an error is received from the API, it must be returned to the page.
redirect() works but doesn't render the page. Just a white screen.
if ($result['error']) {
if (strpos($result['error_description'], 'Task not found')) {
// echo "Неверно введен номер задачи";
return redirect()->route('home');
// die;
}
}
return view('welcome');
private function getTask($request)
{
$number = intval($request->number);
$queryUrl = 'https://'.HomeController::DOMAIN.'.bitrix24.ru/rest/71/000000000000/task.item.getdata.json';
$queryData = http_build_query(array(
'TASKID' => $number
));
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_POST => 1,
CURLOPT_HEADER => 0,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $queryUrl,
CURLOPT_POSTFIELDS => $queryData,
));
$result = curl_exec($curl);
curl_close($curl);
$result = json_decode($result, 1);
if ($result['error']) {
if (strpos($result['error_description'], 'Task not found')) {
echo "Неверно введен номер задачи";
return view('welcome');
// die;
}
}
dd($result);
}
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