php - laravel how to send request o a controlle with parameter -


i working on laravel 5

this controller

<?php  namespace app\http\controllers;  use app\user; use app\http\controllers\controller;  class requestcontroller extends controller {      public function sendrequest($endpoint, $body)     {          return view('response', "d");     } }  ?> 

and in route handle this:

route::post("/request/send", 'requestcontroller@sendrequest'); 

then in html do

<form method="post" action="/request/send">         <textarea id="code" contenteditable="true" name="body"></textarea>         <input type="text" value="d" name="endpoint" />         <input type="button" id="formattcode" value="format"/>         <input type="submit" value="send"/>     </form> 

as see, have body , endpoint in html

however getting error

errorexception in requestcontroller.php line 11: missing argument 1 app\http\controllers\requestcontroller::sendrequest() 

accessing values passed parameters post request done via request instance:

namespace app\http\controllers;  use app\user; use app\http\controllers\controller; use illuminate\http\request;  class requestcontroller extends controller {      public function sendrequest(request $request)     {         $endpoint = $request->input('endpoint');         $body = $request->input('body');          // stuff     } } 

you cand read more in laravel http requests documentation.


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -