Home > Blockchain >  can i make post request using url like "/box?cnb=s3" in laravel route?
can i make post request using url like "/box?cnb=s3" in laravel route?

Time:12-10

I am trying to make a post request that saves the user data on the first step in the create-box-form-blade.php

create-box-form-blade.php

@extends('layouts.home')

@section('content')

{{ csrf_field() }}
<form name='basics' action='/box?cnb=s3' method='post' enctype='multipart/form-data'>

    <fieldset>
    <input type=''  required value='$price' name='price' min='$price' max='$price'>
    <input type='text'  required value='' placeholder='Youtube channel name' name='page_name'>
    <input type='number'  required value='' placeholder='Number of subscriptions you will initially accept' name='box_supply' min='1' max='1000000'>
    </fieldset>
    <fieldset>
    <label>Do you need help with product curation?</label>
    <label>Yes
    <input type='radio' id='disable' value='1' checked name='curation'/>
    </label><label>
    No
     <input type='radio' id='removeDisabled' value='0' name='curation'/>
    </label>
    </fieldset>
   <fieldset>
    <input class='optional' type='number' disabled required name='num_products' placeholder='Number of products in box' min='1' max='25'>
    <input class='optional' type='number' disabled required value='' placeholder='Weight of box in pounds' name='box-weight' min='1' max='1000000'>
    <input class='optional' type='number'  disabled required value='' placeholder='Length of box in inches' name='box-length' min='1' max='1000000'>
    <input class='optional' type='number'  disabled required value='' placeholder='Width of box in inches' name='box-width' min='1' max='1000000'>
    <input class='optional' type='number' disabled required value='' placeholder='Height of box in inches' name='box-height' min='1' max='1000000'>
    </fieldset>
    <input type='hidden' value='basics' />
    </fieldset><fieldset>
     <input type='submit' value='Save' />
     </fieldset>
    </form>
</div>

@endsection

in web.php

Route::post('/box?cnb=s3', 'App\Http\Controllers\BoxController@step2')->name('box.step2');

but I get this error below when i click the save

The POST method is not supported for this route. Supported methods: GET, HEAD.

CodePudding user response:

You can use like post request like

Route::post('/box', 'App\Http\Controllers\BoxController@step2')->name('box.step2');

In that step2 function, you can call pass the queryConditions in that function.

like ->

 public function step2(Request $request)
    {
     if (isset($requestQueryString['cnb'])) {
        $queryConditions = ['cnb' => $requestQueryString['cnb']];
        //and play with your conditions you need it..
    }
}
  • Related