Support the ongoing development of Laravel.io →
Configuration Requests Testing
Last updated 2 years ago.
0

First of all i was unable to open the error link.

Now, the problem

By convention the show() method is used to show a single record by id or any other field and has Route::get request.

 //Route
Route::get('post/{id}', 'PostController@show');
 
//Method
class PostController extends BaseController
  {
    public function show($id)
    {
//$id will be used to retrieve single record from model 
      $post = new stdClass(); #
      $post->title = 'Magneto';
      return View::make('post/show')->with('post', $post);
    }
  }

if you really need to post something to show() method you have to send a post request in these two ways. 1.Use a form 2.Use a browser extension to post Because you cannot send the 'post' request just using the browser address bar. When you write anything in the browser address bar by default it is a 'get' request . And change your code to:

//Route
Route::post('post', 'PostController@show');
 
//Method
class PostController extends BaseController
  {
    public function show()
    {
//Use Request facade to retrieve the posted data 
//The Request facade will grant you access to the current request that is bound in the container.

     Request::input('title');
// The parameter inside input() "title" is the key that you posted from browser and has a value.
      
      $post = new stdClass(); #
      $post->title = 'Magneto';
      return View::make('post/show')->with('post', $post);
    }
  }

if any of these doesn't work take a look at the : Request chapter at laravel docs

Last updated 8 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

HMS10 hms10 Joined 4 Sep 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.