Ad
Limit Access To Route By Parameter Value
I have a route like the following :
Route::group([
'prefix' => 'reports'
], function () {
Route::get('/points/{product_name}', ['uses' => '[email protected]'])->where('product_name', ['product1', 'product2','product3'])
});
So I would like to limit the access to this endpoint id the product name is product1
, product2
, product3
. But with the where
clause, I can only see checking with regular expression or a single value.
When I use an array like ['product1', 'product2', 'product3']
, but it is throwing an error "message": "Routing requirement for "product_name" must be a string."
How can I solve this?
Ad
Answer
For routes in laravel u can use it like this:
where('product_name', 'product1|product2|product3'])
or whith array:
where('product_name', implode("|", ['product1', 'product2','product3']))
Ad
source: stackoverflow.com
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
Ad