0

I am making a test api with dingo and laravel 5.1 but i don't know why my code do not work as i expected. This is just a simple example but it's not work, please help me. This is my route code:

$api = app('Dingo\Api\Routing\Router');

Route::get('/', function () {
    return view('welcome');
});

//this function help use to manage functions on each version. this is version 0.1 (called version groups)
$api->version('v0.1', [ 'namespace'=>'App\Http\Controllers\Api'], function ($api) {
    $api->get('users/{id}', 'TestController@test');
    $api->get('users/{id}', ['as' => 'users.index', 'users' => 'TestController@test']);//make route
    app('Dingo\Api\Routing\UrlGenerator')->version('v0.1')->route('users.index');//finally, create new route
    //Route::get('/users/{id}', 'UserController@show');
});

And this is my TestController code:

namespace app\Http\Controllers\Api;


use app\Http\Controllers\BaseController;

class TestController extends BaseController
{
    public function test($id){
        return $id;
    }
}

Very basic but it is not work when i try to get it from Postman, these code return a jason like this:

"message": "Function () does not exist",
"status_code": 500,

I am looking forward to your help, Thank you.

duong khang
  • 342
  • 1
  • 4
  • 19
  • Have you tried to include the parameter closure of the _version_ method inside the associative array? I had a similar problem before... maybe it's the same thing :) – Francesco Malatesta Sep 08 '15 at 06:53
  • Thank you for your reply!, i found the error. It's shame on me cause i change 'uses' to 'users', it cause error on the api. :D. – duong khang Sep 08 '15 at 06:59

0 Answers0