For a Laravel 5.5 project I solved a permission problem that I’d like to share in case someone else can benefit.
The structure of our urls look like this:
Which will show all the companies for user 5. I however wanted to limit it so that only user 5 may see user/5 company listings. User/4 or another use should see access denied when viewing /users/5/companies.
My current route was defined this way in routes/web.php: