jeudi 1 décembre 2016

Request not found error in laravel controller

I have Laravel version 5.3 and i created a file createArticleRequest.php under the request folder , which looks like below:

<?php namespace App\Http\Requests;

use App\Http\Requests\Request;

class CreateArticleRequest extends Request {


    public function authorize() {
        return true;
    }

    public function rules() {
        return  [
            'title' => 'required|min:3',
            'body'  => 'required',
            'published_at'  => 'required|date',
        ]
    }


} 

?> 

In My articles controller i have the following method:

public function store(CreateArticleRequest $request) {
        // $input = Request::all();
        Article::create($request->all());
        return redirect('articles');
}

But when i fill the form in my view and click on submit i get an error like so:

ReflectionException in Route.php line 286:
Class App\Http\Controllers\CreateArticleRequest does not exist

Why am i getting this error ??

I believe my articles Controller and my createArticlesRequest are in the same namespace so why am i getthing this error?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire