ReflectionException in RouteDependencyResolverTrait.php error in creating request validation - Laravel -
i have problems code. following tutorial in laravel 5. doing form validation got error , don't know how did happened. new laravel.
i creating article sample.
here's controller:
<?php namespace app\http\controllers; use app\article; use app\http\requests; use app\http\controllers\controller; //use illuminate\http\request; use carbon\carbon; //use request; class articlescontroller extends controller { public function index() { //$articles = article::all(); //$articles = article::latest('published_at')->where('published_at', '<=', carbon::now())->get(); /** select * articles published_at <= now() order published_at desc */ $articles = article::latest('published_at')->published()->get(); return view('articles.index', compact('articles')); } public function show($id) { $article = article::findorfail($id); //dd($article->published_at); return view('articles.show', compact('article')); } public function create() { return view('articles.create'); } public function store(createarticlerequest $request) { //$input = request::all(); //$input['published_at'] = carbon::now(); //$title = request::get('title'); article::create($request->all()); return redirect('articles'); } }
here's request
<?php namespace app\http\requests; use app\http\requests\request; class createarticlerequest extends request { /** * determine if user authorized make request. * * @return bool */ public function authorize() { return true; //permissions } /** * validation rules apply request. * * @return array */ public function rules() { return [ 'title' => 'required|min:3', 'body' => 'required', 'published_at' => 'required|date' ]; } }
my route:
<?php /* |-------------------------------------------------------------------------- | application routes |-------------------------------------------------------------------------- | | here can register of routes application. | it's breeze. tell laravel uris should respond | , give controller call when uri requested. | */ route::get('/', 'welcomecontroller@index'); route::get('home', 'homecontroller@index'); route::controllers([ 'auth' => 'auth\authcontroller', 'password' => 'auth\passwordcontroller', ]); route::get('articles','articlescontroller@index'); route::get('articles/create','articlescontroller@create'); route::get('articles/{id}','articlescontroller@show'); route::post('articles','articlescontroller@store');
when checked doesn't allow me insert in database.
it throwing reflectionexception because using wrong class. should use app\http\requests\createarticlerequest
instead of app\http\requests
in articlescontroller
Comments
Post a Comment