Я тестирую свой API, поэтому хочу создавать запросы, но я не могу заставить параметры работать. Все, что я делаю, это добавить параметр с Hello, указывающим на World, но Hello возвращает NULL, когда я пытаюсь получить этот параметр. Чего не хватает? Вот код:Laravel: Не могу добавить параметры для запроса
//This is routes.php:
<?php
Route::get('/testapi', '[email protected]');
Route::get('/json/locations', '[email protected]');
?>
//This is TestController.php:
<?php
class TestController extends \BaseController {
public function testapi() {
echo 'Create the request';
echo '<br>';
$request = Request::create('/json/locations', 'GET', array('Hello' => 'World'));
return Route::dispatch($request)->getContent();
}
}
?>
//This is APILocationController.php:
<?php
class APILocationController extends \BaseController {
public function getForUser() {
echo var_dump(Request::get('Hello'));
echo '<br>';
return Response::json(array('message' => 'Index all locations based on User'), 200);
}
}
?>
//This is the output:
Create the request
NULL
{"message":"Index all locations based on User"}
// Как это "NULL"?
Все еще возвращает NULL:/ – Rkey
Как вы это проверяете? – Jerodev
С таким же кодом, который я только что вставил, я просто заменил Request :: get with Input :: get – Rkey