Hello,
I'm trying to pass the data of the form to the post route, but I always get the "MethodNotAllowedHttpException". I don't know why. I hope someone can help me. Thank you :)
...Here is the form code:
<form action="/backoffice/customer/create/" method="POST" accept-charset="UTF-8">
<div class="row">
<div class="col s4">
<input class="inputNewCustomer" type="text" name="newCustomerInput" maxlength="25" placeholder="Name of Customer">
<input name="_token" type="hidden" id="_token" value="{{ csrf_token() }}" />
</div>
<div class="col s8">
<button class="btn waves-effect waves-light light-green" type="submit" value="Save">create Customer</button>
</div>
</div>
</form>
....Here is the route:
Route::post('backoffice/customer/create', [
'as' => 'createCustomer', 'middleware' => 'auth', 'uses' => 'BackofficeController@createCustomer'
]);
....and the function in the controller:
public function createCustomer(){
$customer = new Customer;
$customer->customer_name = Input::get('newCustomerInput');
$customer->save();
//Log::debug("test");
//displayCustomers();
return Redirect::to('backoffice/customer');
}
open dev tools and see if your browser is actually doing a POST not a GET
also try changing action="/backoffice/customer/create/" to action="{{ route('createCustomer') }}"
astroanu said:
open dev tools and see if your browser is actually doing a POST not a GET
also try changing action="/backoffice/customer/create/" to action="{{ route('createCustomer') }}"
Hi, yeah it works with action="{{ route('createCustomer') }}"
thank you ;)
Is it that last / in action ?
/backoffice/customer/create
Instead of
/backoffice/customer/create/
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community