Hey,
im struggling with a custom route. I have also tried a simple one and im getting “'No route found for path: “get-book-code” and request method: “GET””.
Im using valet with php 8.1 working locally.
any hint? httaccess should be modified?
<?php
return [
'routes' => [
[
'pattern' => 'api/get-book-code',
'method' => 'GET',
'action' => function () {
$codesPage = page('bookcodes');
$bookCodes = $codesPage->bookCodes()->toStructure();
foreach ($bookCodes as $index => $code) {
if ($code->claimed()->toBool() === false) {
$updatedCodes = $bookCodes->toArray();
$updatedCodes[$index]['claimed'] = 'true';
$codesPage->update([
'bookCodes' => yaml::encode($updatedCodes)
]);
return [
'code' => $code->code(),
];
}
}
return [
'status' => 'error',
'message' => 'All codes have been claimed.'
];
}
]
]
];
<?php
return [
'debug' => true,
'routes' => [
[
'pattern' => 'api/test',
'method' => 'GET',
'action' => function () {
return [
'status' => 'success',
'message' => 'This is a test endpoint.'
];
}
]
]
];