我正在处理Laravel
5.6,
我正在创建一个函数,它接收我希望在表格路径中插入的三个参数($name_route, $description_route, $photo_route)
,但我有以下错误无法解释:<\ n / p>
"Type error: Too few arguments to function App\\Http\\Controllers\\RoutesController::createRoute(), 0 passed and exactly 3 expected in RoutesController.php (64)"
如果我传递这三个变量,我做错了什么?我正在使用Swagger
进行测试。
以下是我在路线档(routes.php)
中设置的方式:
/** ***********************************************************
* Logged user can create a route
* ************************************************************
* @SWG\Post(
* tags={"Routes"},
* path="/api/v1/routes/route/create",
* summary="Logged user can create a route",
* @SWG\Parameter(ref="#/parameters/Accept"),
* @SWG\Parameter(ref="#/parameters/apikey"),
* @SWG\Parameter(ref="#/parameters/Language"),
* @SWG\Parameter(ref="#/parameters/Authorization"),
* @SWG\Parameter(name="name", in="path", type="string"),
* @SWG\Parameter(name="description", in="path", type="string"),
* @SWG\Parameter(name="photo", in="path", type="string"),
* @SWG\Response(response=HTTP_CODE_200_OK, description="Routes",
@SWG\Schema(ref="#/definitions/RouteDetail")),
* )
*/
Route::post('/route/create', 'RoutesController@createRoute')->middleware('auth:api');
我的控制员:
/**
* @param $name_route
* @param $description_route
* @param $photo_route
*/
public function createRoute($name_route, $description_route, $photo_route)
{
$route = new Route();
$route->user_id = $this->input($this->user()->id);
$route->name = $this->input($name_route);
$route->description = $this->input($description_route);
$route->photo = $this->input($photo_route);
$route->save();
}