I am building a simple Laravel routing to display an array when someone goes to http://127.0.0.1:8000/planets But I need to make a filter to check the array on what request has been send on the URL. For example: http://127.0.0.1:8000/planets?planet=mars I need to make sure that if a GET parameter is present, …
Tag: laravel-routing
Laravel model user custom binding “/users/me/xxx”
I have routes with user binding like So I can use /users/1/posts, /users/5/posts etc, and in controller it’s automatically available thanks to model binding But for current logged user I want to make possible to also use /me/ instead ID, like /users/me/posts Is there a way to make it without defining se…
routes/web route me to another route
My web doesn’t seem to be directing to the correct page. Here is my blade Here is my routes/web and here is my controller For some reason, when I click the a tag with the href {{ route(‘add-new-information’) }} to go to the add page ‘adminviews/addinfo’, instead the page will go …
Laravel 8 redirect web routes
It seems there is an error in my Laravel 8 routes somewhere. My web routes file: When going to /, it is redirected to /en. But when going to /dashboard it isn’t redirected to /dashboard/en but gives an error: As can be seen, not a lot of information given. Anyone knows what to do? Answer Found it: Larav…
What is the cause of this route-related error in my Laravel 8 application?
I am working on a Laravel application that requires user registration and login. Alter registration, the users have the possibility to replace the default avatar image with a picture of their choice. They should also be able to delete this picture and revert to the default avatar (default.png). For this purpo…
Laravel doubles the route when navigating between navbar links
I have a problem with laravel routes. I have a navbar with the urls /products and /employee. I manage to switch between perfectly perfectly without giving error. However, when I access the link /products/new and from there I try to go back to /products or go to /employees through the navbar, the link is /prod…
Ways to write Laravel routes
Is there a better way to write these routes? It seems I am repeating the same controller in my route files. Answer You can use a resource route, where you specify a subset of actions in the controller. You can also use the –model option when generating a controller with the stubbed out CRUD methods. Res…
Laravel: Passing data into route from database
I have created a theme system and I am trying to make the theme’s route file pull pages from the database and assign a route to it, below is my theme route file. The issue I am having is an Undefined variable: theme from my ThemeSettings::all model request. Route.php (In theme) ThemeSettings Migration T…
Laravel API – Showing individual file through o2m relationship
So I have two models User and File, these are connected with a one-to-many relationship. I have sorted the API routes and controllers to index all users, show specific user and index all files uploaded by that specific user. I do not know how to write the logic that will allow this route 127.0.0.1:8001/api/2/…
Can’t access the Auth::user() from a custom route file ? Laravel 7
For a purpose i decided to create a separate routing file for the admin and separating its logic from the web.php but instead i am facing this issue : ps: the admin.php is registered in the RouteServiceProvider Answer Add web middleware