I have an AuthController in my laravel app, inside that controller i have several methods:
public function postLogin(LoginRequest $request)
{
...
}
public function getRegister()
{
...
}
public function postRegister(RegisterRequest $request)
{
...
}
For some reason now my postRegister()
function does not work, when I run it in postman for some reason it always executes getRegister()
instead, when i take out getRegister()
it says Controller method not found.
This is my route:
Route::group(['prefix' => '/api/v1/', 'namespace' => 'App\Http\Auth\Controllers'], function() {
/**
* Authentication
*/
Route::controllers([
'auth' => 'AuthController',
'password' => 'PasswordController',
]);
});
Edit: I have narrowed the issue down to my request file, the path is correct but for some reason when i try to use it in postRegister(RegisterRequest $request), the postRegister function does not get executed, no errors are thrown, it worked before now i have no idea what is causing this issue now.
I think i should also add that i created custom namespaces which i am using in my application.
After hours of searching and changing my code i found a solution here: laracasts.com/discuss/channels/laravel/laravel-5-custom-request-not-working
Apparently when using postman to test your APIs in laravel you need to set the AcceptHeader
to Application/json
. I did not know this. :)