mardi 2 août 2016

ReflectionException, class does not exist

Giving the next code I'm getting this error:

ReflectionException in Route.php line 286: Class App\Http\Requests\ApiRegisterRequest does not exist

Routes

Route::group(['prefix' => 'api/v1'], function() {
    Route::post('login', 'API\ApiController@authenticate');
    Route::post('register', 'API\ApiController@register');
});

ApiController

namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;

class ApiController extends Controller
{
    public function register(\App\Http\Requests\ApiRegisterRequest $request)
    {
        dd($request);
    }
}

ApiRegisterRequest

namespace App\Http\Requests;

use App\Http\Requests\Request;

class ApiRegisterRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'first_name' => 'required:min:3',
            'email' => 'required'
        ];
    }

    public function messages()
    {
        $messages = [
            'first_name.required' => 'Has de introducir un nombre'
            'email.required' => 'Has de introducir un correo'
        ];

        return $messages;
    }
}

What am I doing wrong?





Aucun commentaire:

Enregistrer un commentaire