0

I need to show a blade page for editting things from the main page. The problem is that I'm using Laravel for editing things without a Model, the things are not on my application databases.

In the main page I have all that I need for the "edit page" and I do not want to make another request to the "api server" to get again the data. -this means that a "GET" request with the "id" is not enough-

So I try to build a Link like that:

href="{{ URL::route('edit.txt', [$template->content->templateId,
                                                    'template'=>$template,
                                                    'src'=>$src])}}"

then I have the route:

Route::get('/editTxtStepper/{id}','HomeController@editTxtTemplate')->name('edit.txt');

Then I have a controller that does:

 public function editTxtTemplate($idTemp,Request $r){

        $src=$r->src;
        $template=$r->template;
        return view('editStepperHtml')->with('src',$src)->with('template',$template);

    }

This is wrong because all the data going in to the URL and breaks some servers with the classic error:

Request-URI Too Long The requested URL's length exceeds the capacity limit for this server.

The next thing on my mind is to using a POST request, but is it correct if I'm using it to showing a next page?

Which one is the correct thing to do? I'm using even jQuery and ajax in the same project so if I need it for quick solutions no problem.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
JahStation
  • 893
  • 3
  • 15
  • 35
  • You can do a post submission to go to the next page, and on your controller, when it ends, return a redirect to a get route, where you send your parameters – Sérgio Reis Mar 12 '18 at 10:51
  • is that the right and fastest way? keep in mind that `$template` is an array: ` {{Form::open(array('route' => array( 'edit.txt', $template->content->templateId )))}} {{ Form::hidden('template',json_encode($template) )}} {{ Form::hidden('src',$src) }} {{Form::close()}}` – JahStation Mar 12 '18 at 11:32
  • Sending long data on the url isn't a good practice, long data might be better off using POST requests, and in your controller, returning a redirect isn't really something slow. – Sérgio Reis Mar 12 '18 at 11:38
  • thats a post request isnt? I change the route aswell – JahStation Mar 12 '18 at 11:41
  • Yes, in your route, the one you place on your form, it should be changed to `Route::post` , then, add another route, this one a get, that is your second page, so you redirect to it in the end of the post – Sérgio Reis Mar 12 '18 at 11:45

0 Answers0