Is it possible to make Ajax PATCH requests to Laravel, or am I restricted to POST? Laravel uses PATCH in input hidden fields. However, I am not using form elements—just buttons that should partially update a record when clicked (via an Ajax request).
How would the route look like for this?
Routes file
Route::patch('questions/{id}', 'QuestionController@update')->before('admin');
I am not sure if Laravel routes support PATCH.
Controller
public function update($id) {
if (Request::ajax() && Request::isMethod('patch')) {
//partially update record here
}
}
JavaScript
$('div#question_preview <some button selector>').click(function (event) {
$.ajax({
url: 'questions/' + question_id,
type: 'PATCH',
data: {status: 'some status'}
});
});