So I am trying to make restful web request but, I may have configured it wrong which I cannot seem to fix.
I have mind that.
/companies GET -> index method
/companies POST -> add post method
/companies/1 GET -> show method
/companies/1 POST -> edit post method
Here is what I have tried
"router" => [
"routes" => [
"companies" => [
"type" => "segment",
"options" => [
"route" => "/companies[/:id]",
"constraints" => [
"id" => "[0-9]*",
],
"defaults" => [
"controller" => Controller\CompaniesController::class,
"action" => "index",
],
],
"may_terminate" => true,
"child_routes" => [
"companiesIndex" => [
"type" => "segment",
"options" => [
"verb" => "GET",
"route" => "/companies",
"defaults" => [
"controller" => Controller\CompaniesController::class,
"action" => "index"
],
],
],
"companiesAddPost" => [
"type" => "segment",
"options" => [
"verb" => "POST",
"route" => "/companies",
"defaults" => [
"controller" => Controller\CompaniesController::class,
"action" => "add"
],
],
],
"companiesShow" => [
"type" => "segment",
"options" => [
"verb" => "GET",
"route" => "/companies/:id",
"constraints" => [
"id" => "[0-9]*",
],
"defaults" => [
"controller" => Controller\CompaniesController::class,
"action" => "show"
],
],
],
"companiesEditPost" => [
"type" => "segment",
"options" => [
"verb" => "PATCH",
"route" => "/companies/:id",
"constraints" => [
"id" => "[0-9]*",
],
"defaults" => [
"controller" => Controller\CompaniesController::class,
"action" => "edit"
],
],
],
],
],
/companies
index method works. Not sure about Post. But whenever I try to request /companies/1
it still shows index method. What is wrong and how should I fix it.