So I am working with a Laravel 5 installation and like a good programmer I am trying to get the validation logic out of my controller using the new Form Requests feature in Laravel.
So I went ahead and created a form request called CreateTenantRequest like so:
php artisan make:request CreateTenantRequest
By default it returns a false in the authorize method and it works correctly. If I fire a request, it says forbidden. But then I updated the rules and I set the authorize method to true and now when I fire the same request from Postman, it says:
NotFoundHttpException in RouteCollection.php line 161:
Which is ridiculous because when I change it to false, it returns forbidden fine?
What am I missing or doing wrong?
And although this wouldn't matter I guess but my rules array is as follows:
return [
// Tenant details
'name' => 'required|max:255',
'username' => 'required|max:255|unique:tenant',
// Tenant Admin details
'first_name' => 'required',
'last_name' => 'required',
'email' => 'required|email|max:255',
'password' => 'required|confirmed|min:6',
];
Routes file:
<?php
Route::group(['prefix' => 'api'], function(){
Route::post('authenticate', 'Auth\AuthController@authenticate');
// SuperAdmin Group
Route::group(['namespace' => 'Archive', 'middleware' => 'superadmin'], function(){
Route::resource('tenants', 'TenantController');
Route::get('tenants/{id}/users', 'TenantController@showUsersForTenant');
});
// Tenant Group
Route::group(['namespace' => 'Tenant'], function(){
Route::resource('roles', 'RoleController');
Route::resource('users', 'UserController');
});
// Remove before production
// Only for testing purposes
Route::get('test', function(){
// return JWTAuth::parseToken()->getPayload()->get('username');
});
});
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire