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
15
votes
2 answers

Laravel 5: Middleware before & after into routes

I have two Middlewares: beforeCache & afterCache, boths registered on Kernel. I want to call them into routes in this order: 1. beforeCache 2. myController 3. afterCache If I define a route like this: Route::get('especies/{id}', [ 'middleware'…
15
votes
3 answers

Laravel 5 Route Group and Basic(/) GET Route within group

I am working on a Laravel 5.0 Web application with Admin panel. I am facing an issue with Routes. I have Grouped Admin Routes like below, Route::group(['prefix' => 'admin', 'namespace' => 'Admin', 'middleware' => ['user.admin']], function () { …
pinkal vansia
  • 10,240
  • 5
  • 49
  • 62
15
votes
8 answers

Prevent Sessions For Routes in Laravel (Custom on-demand session handling)

I am building APIs for my Android app using laravel and default session driver set to REDIS. I found a good article here http://dor.ky/laravel-prevent-sessions-for-routes-via-a-filter/ which sort of serves the purpose. However when ever I hit the…
ʞɹᴉʞ ǝʌɐp
  • 5,350
  • 8
  • 39
  • 65
14
votes
1 answer

Laravel: how to limit some route parameter to specific values?

Is that possible to make route that accept string parameter only for specific string? Example : Route::get('{user_tipe}/event', 'admin\EventC@index'); That the route, I want to make the user_tipe param is only allow to two string like admin and…
Adi Sparta
  • 525
  • 2
  • 7
  • 23
14
votes
2 answers

Laravel - How to pass variables to middleware through route group?

This is my route group, Route::group(['middleware' => 'checkUserLevel'], function () { // my routes }); And this is my middleware checkUserLevel, public function handle($request, Closure $next, $level) { …
14
votes
5 answers

Make session expiration redirect back to login?

When user logs in and is authenticated, I use Auth::user()->username; to show username of user on dashboard. However, for some reason when session expires the class Auth doesn't seem to work and dashboard page throws error as trying to get property…
Sumit
  • 1,235
  • 4
  • 17
  • 29
14
votes
3 answers

How to make routes in Laravel case insensitive?

I have a project in laravel and there are many routes in that project. But i just discovered that the routes are all case sensitive, means /advertiser/reports is different than /advertiser/Reports . So what i want is both the routes should…
Nishant Srivastava
  • 379
  • 1
  • 2
  • 12
13
votes
5 answers

Should I Nest Routes to Resources in Laravel?

This may be a little subjective, but I feel that best-practice must exist (or even good design when it comes to Laravel apps). Googling results in lots of things that are not to do with the actual points in this question. Say I am building a web…
Elliot
  • 1,457
  • 13
  • 40
13
votes
5 answers

FatalErrorException in HtmlServiceProvider.php line 36: laravel

I am using laravel 5.2 and I am getting following error FatalErrorException in HtmlServiceProvider.php line 36: Call to undefined method Illuminate\Foundation\Application::bindShared() my app.php file is
Murali Krishna
  • 159
  • 1
  • 2
  • 8
13
votes
2 answers

Single Laravel Route for multiple controllers

I am creating a project where i have multiple user types, eg. superadmin, admin, managers etc. Once the user is authenticated, the system checks the user type and sends him to the respective controller. The middle ware for this is working fine. So…
Omer Farooq
  • 3,754
  • 6
  • 31
  • 60
13
votes
3 answers

Laravel 5 Cached Routes not updating

I've cached my Laravel 5 routes by doing php artisan route:cache. This went succesfull for quite a while and when I changed a route is could cache them again and it would all work like it should. The problem is that I've moved some routes to another…
guidsen
  • 2,333
  • 6
  • 34
  • 55
12
votes
2 answers

Laravel 5.4 - How to override route defined in a package?

I have created a package in Laravel 5.4 that sets up a basic backoffice. This package contains several routes that are using controllers from within the package. What I want to be able to do is to override the package defined routes in my…
António Quadrado
  • 1,307
  • 2
  • 17
  • 34
12
votes
4 answers

Search object by slug and not by id

I'm a relative beginner with Laravel (using version 5.2.3) and have been working through tutorials on Laracasts and then doing a bit of my own experimenting. I successfully set up a route that fetches an item from a table by its ID, as shown…
Roxy Walsh
  • 659
  • 1
  • 10
  • 16
12
votes
5 answers

Laravel 5, Sub-Domain routing, with optional parameter

I’ve just started learning Laravel 5 and trying to create multilanguage web site and want to use different domains for the language so en.example.app points to English version, es.example.app to Spanish and so on. I use route groups and below is my…
Teymur
  • 121
  • 1
  • 5
12
votes
3 answers

Laravel route() returning naked IP address instead of domain

Didn't catch this on my local machine but I've noticed some of my pages returning the naked IP address of my web server instead of the domain name. Example: route('homepage') will sometimes return 192.XX8.X.2XX or 192.XX8.X.2XX/index.php or…
Helen Che
  • 1,951
  • 5
  • 29
  • 41