Using php artisan make:request StoreUserData
I've create my rules to the request:
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreUserData extends FormRequest {
public function rules(){
return [
'name'=>'required|integer',
'surname'=>'required|max:255|string',
];
}
}
And I'm trying to use it in controller
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class UserDataController extends Controller {
public function store(StoreUserData $request){
return 'valid';
}
}
Here the error I get: Class App\Http\Controllers\StoreUserData does not exist.
PS. Is not a problem of routing. I'm following this documentation since I'm using Laravel 5.6 https://laravel.com/docs/5.6/validation#creating-form-requests
composer dump-autoload
– J. DoeStoreUserData
, try addinguse App\Http\Requests\StoreUserData
in your controller – rkj