php - Laravel 4 resource controller show($id) method problems -


does have 'id' column in database table works fine show($id), edit($id) method in controller?
want replace $id value of 'post_id' column in database table, throws error: modelnotfoundexception
how can fix it?

sample code:

database table:

id(int), post_id(varchar32), post_title(varchar32), post_content(text)

routes:

route::resource('posts', 'postscontroller');

postscontroller:

public function show($id) { return view::make('posts.show'); }

when visit http://localhost/posts/1 should return view of post has id 1 in table.
if return view based on post_id value in table?
have replace parameter in show() or ?

in postscontroller need access post model data db.

like this: //postscontroller

public function show($id) {  $post = post::where('post_id', $id)->first();  return view::make('posts.show', compact('post'));  } 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -