Why not just change it to GET, since that's what you are actually doing when the user clicks the button. You're not POSTing data, you're GETting it. action_url is just an anchor tag to go to a different page when the user clicks it.
Jul 13, 2017
1
Level 3
Is it possible to specify an HTTP method in a Spark notification?
I'm using Spark notifications as documented here:
https://spark.laravel.com/docs/4.0/notifications
Here's my code block to create the notification:
$this->notifications->create($post->user, [
'icon' => 'fa-exclamation-triangle',
'body' => "My message to the user here",
'action_text' => 'Reactivate Post',
'action_url' => '/posts/' . $post->id . '/reactivate',
]);
Here's my route:
Route::post('/posts/{post}/reactivate', 'PostsController@reactivate')->where('post', '[0-9]+')->middleware('postToReactivateValid');
I'm getting a "MethodNotAllowedHttpException". This is because the action_url link is sending the request with a GET http method and my route accepts a POST http method.
Is there anywhere in creating the Spark notification to specify the HTTP method to use?
Please or to participate in this conversation.