Questions tagged [laravel-routing]

Routing in Laravel Framework's MVC implementation. Laravel is a free, open source PHP web application framework, and it is released under the MIT license.

laravel-routing is a tag suitable for any questions regarding routing in Laravel's MVC implementation, url handling, or any other matter affecting or affected by routing in Laravel.

2207 questions
12
votes
3 answers

How to run laravel 5 on port 80 of localhost?

For previous versions of Laravel, you can simply download laravel with composer in the root folder of your apache server and type in http://localhost/public/ to see the "You've arrived" homepage. I know I can use php artisan serve to view the…
cytsunny
  • 4,838
  • 15
  • 62
  • 129
11
votes
1 answer

Laravel 9 - Show middleware in artisan route:list

How to display/show middleware used in Laravel routing? php artisan route:list
keatflame
  • 531
  • 4
  • 7
11
votes
2 answers

Laravel 5.6 additional Route::resource() Parameters

I would like to know how to add additional parameters to Laravel's Route Resource without using Query Strings. I created a controller (CustomerController) with all the built-in resources and then, added the following…
Ricky
  • 2,912
  • 8
  • 47
  • 74
11
votes
3 answers

Laravel : How to hide url parameter?

Here the scenario is I want to pass a variable which will be send from one page to another and in next page it's gonna store through a form. So I have passed the variable from first page to second page through the URL. But I want to hide the…
Hola
  • 2,163
  • 8
  • 39
  • 87
11
votes
2 answers

User Auth not persisting within Laravel package

This is my first attempt at a laravel package and have run into an issue where Auth::attempt($credentials) works within my login controller, but upon redirection to a protected route or controller, the user is no longer authenticated. Below is my…
Will
  • 383
  • 3
  • 12
11
votes
2 answers

Restrict route access to non-admin users

Goal I'm trying to create Admin route restriction for my log-in users. I've tried a check to see if my user is log-in, and also if the user type is Admin, and if they are, I want to allow them access to the admin route, otherwise, respond a…
11
votes
1 answer

Dynamic middleware for laravel 5

While building multi-tenancy packages for Laravel 5 I had to find out how to add middleware dynamically from code. In comparison to this question on SO I do not want to touch the Http/Kernel definitions. During application initialization I check…
Luceos
  • 6,629
  • 1
  • 35
  • 65
11
votes
3 answers

Difference between URL::to and URL::route in laravel

What is the difference between Register 1 and Register 2 I defined the routes.php as…
Kiran Subedi
  • 2,244
  • 3
  • 17
  • 34
11
votes
2 answers

Laravel 4 route with unlimited number of parameters

I'm trying to create a dynamic route for an unlimited number of URL levels. Here's my current route Route::get('{pageLink}', array('uses' => 'SiteController@getPage')); This works for the first level. So a URL like something.com/foo/ would work.…
David Maksimov
  • 369
  • 5
  • 17
11
votes
1 answer

Laravel: How to respond with custom 404 error depending on route

I'm using Laravel4 framework and I came across this problem. I want to display a custom 404 error depending on requested url. For example: Route::get('site/{something}', function($something){ return…
10
votes
2 answers

Route to controller in Laravel 8

I'm working with Laravel 8 and when I write the route to the __invoke controller like this: use App\Http\Controllers\PortfolioController; Route::get('/portfolio', 'PortfolioController')->name('portfolio'); It shows this error: Invalid route…
Jota
  • 117
  • 1
  • 1
  • 7
10
votes
2 answers

Laravel Route issues with Route order in web.php

I have problem with routes in Laravel, I'm following one tutorial and we have this routes listed in web.php file Route::get('/home', 'HomeController@index')->name('home'); Route::get('/blog',…
Igor Šumonja
  • 101
  • 1
  • 5
10
votes
2 answers

Laravel 5 POST routes to index instead of store

I am working on a Laravel 5 RESTful API that seems not to be routing the POST requests correctly. This is my routes.php: Route::group(array('prefix' => 'api/v1'), function() { Route::resource('messages', 'IncomingMessages'); }); And this is my…
GorkaU
  • 343
  • 3
  • 13
10
votes
5 answers

Laravel 5 MethodNotAllowedHttpException in RouteCollection.php line 201:

I have a number of php files in my project: admin.blade.php: this files contains the admin form. When called it show the following error: MethodNotAllowedHttpException in RouteCollection.php line 201

Please Log In To Manage

deep singh
  • 339
  • 3
  • 5
  • 14
10
votes
3 answers

laravel route filter to check user roles

I am building a restful api in laravel 4 where there are users with different types of permission. I want to restrict access to different routes depending on the user role (which is saved in the user table in db) How would I do that? Here is what…
user1424508
  • 3,231
  • 13
  • 40
  • 66