php - Missing route error in laravel 4 -
php - Missing route error in laravel 4 -
i'm learning laravel , practice making simple blog app. have failed update article. route missing , going "my slug route" @ bottom of code , throw error. error slug not found, that's okay. why route missing? other routes working create,delete etc. fault? note: sorry bad english.
edit.blade.php
{{ form::open(array('url'=>'update', 'method'=>'patch')) }} <input type="hidden" name="id" value="{{ $article->id }}"> <input type="text" name="title" placeholder="title" value="{{ $article->title }}" /> <textarea type="text" name="body" placeholder="body">{{ $article->body }}</textarea> <input type="text" name="tags" placeholder="tags" value="{{ $article->tags }}" /> <input type="submit" value="update" > {{ form::close() }}
routes.php
route::post('update', array( 'uses' => 'homecontroller@update' ))->before('auth'); route::get('/{slug}', function($slug){ setlocale(lc_time, "tr,tr", "tr" , "turkish"); $article = article::where('slug', $slug)->first(); $comments = $article->comments()->where('approve', '=', 1)->get(); $date = $article->created_at; $date = iconv('latin5','utf-8',strftime('%a %d %b %y')); homecoming view::make('article', array( 'article' => $article, 'date' => $date, 'comments' => $comments )); });
and homecontroller.php
public function update(){ $rules = array( 'title' => 'required|min:5|max:255', 'body' => 'required|min:10', 'tags' => 'required|min:5|max:100' ); $validator = validator::make(input::all(), $rules); if ($validator->fails()) { homecoming redirect::back()->witherrors($validator); } $id = input::get('id'); $article = article::find($id); $article->title = input::get('title'); $article->body = input::get('body'); $article->tags = input::get('tags'); $article->save(); homecoming redirect::back()->with('message', 'article updated successfully.'); }
you have done
'method'=>'patch'
but route is
route::post('update'...
change route this
route::patch('update'...
php laravel routing crud
Comments
Post a Comment