Reputation: 1826
I create a from to send a DELETE method to server, the code looks like this:
{Form::open('company/'.$company->id, 'DELETE', array('style'=>'display: inline'))}}
{{Form::hidden('id', $company->id)}}
{{Form::submit('Delete')}}
{{Form::close()}}
However I already created an alias for this delete route, looks like bellow:
Route::get('company/(:num)',array('as' => 'delete_company', 'uses'=>'company@destroy'));
How do I use the alias in this case instead of explicitly write it out as above?
Upvotes: 0
Views: 920
Reputation: 2037
If you mean to ask on how to get the URL to that named route, here is what you need to do in L3
$url = URL::to_route('delete_company', array($company->id));
Form::open($url);
I am not sure if you can do a DELETE http request with a form, as forms only support POST and GET, you may need to use a javascript library like Angularjs, backbone or jquery.
It seems this is possible in Laravel, see the comment below :)
Upvotes: 1