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
8
votes
4 answers

Laravel form won't PATCH, only POST - nested RESTfull Controllers, MethodNotAllowedHttpException

I am trying to allow users to edit their playlist. However, whenever I try to execute the PATCH request, I get the MethodNotAllowedHttpException error. (it is expecting a POST) I have set up RESTful Resource…
maarten
  • 123
  • 1
  • 1
  • 6
8
votes
3 answers

Can route model binding be used with RESTful controllers?

I have been using RESTful controllers in my Laravel project. By including: Route::controller('things', 'ThingController') in my routes.php, I can define functions in the ThingController like: public function getDisplay($id) { $thing =…
Don't Panic
  • 41,125
  • 10
  • 61
  • 80
8
votes
2 answers

Laravel 4 : How to pass multiple optional parameters

I am new to laravel and I am really struggling to understand how to pass multiple optional url parameters. What is the standard way to code routes when passing 3 optional parameters to the controller? Also is there a way to code a route to allow…
user3631427
  • 83
  • 1
  • 3
7
votes
2 answers

Laravel route to check for multiple string

I want redirects (301) for some routes which contains the following - page=1 (query string) or index.php or ?&(query string) I have added the route as - Route::get('/{any_url}', 'UsersController@processRedirect')->where('any_url',…
Sougata Bose
  • 31,517
  • 8
  • 49
  • 87
7
votes
3 answers

Getting route parameters in Lumen

When trying to access Route parameters, using $request->route('id'), in latest version of Lumen, I get an error. lumen.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function parameter() on array It works fine in…
Zoon
  • 1,068
  • 2
  • 11
  • 26
7
votes
3 answers

Laravel grouping routes what is best prefix or middleware

When I start thinking grouping my routes and check the documentation. I lost there. There are too many things like prefix, middleware etc. What is the best way to group routes? Route::group(['middleware' => 'admin'], function ()…
Shahid Karimi
  • 4,096
  • 17
  • 62
  • 104
7
votes
3 answers

How to exclude slugs from a Laravel route pattern

I have a Laravel Spark application, and would like to use the first two parameters in a route for team and project, with exceptions like about_us, settings, api etc. I have set up my routes, similar to: Route::pattern('team',…
Elliot
  • 1,457
  • 13
  • 40
7
votes
5 answers

Class Controller not found in laravel 5

So I am new to laravel and was just trying out some code to clear the basics,but however after creating a new controller to handle a route.It throws a fatal exception saying Class 'Controller' not found! (The controller.php exists in the same…
gospelslide
  • 179
  • 2
  • 2
  • 12
7
votes
3 answers

TokenMismatchException in VerifyCsrfToken - Laravel 5.1

I am building a REST API using Laravel 5.1 and I am getting this error: TokenMismatchException in VerifyCsrfToken.php line 53: Here is my routes.php: Route::controller('city' , 'CityController' ); CityController: class CityController extends…
Chandz
  • 1,173
  • 3
  • 18
  • 34
7
votes
1 answer

How to use laravel routing for unknown number of parameters in URL?

For example, I'm publishing books with chapters, topics, articles: http://domain.com/book/chapter/topic/article I would have Laravel route with parameters: Route::get('/{book}/{chapter}/{topic}/{article}', 'controller@func') Is it possible, in…
greener
  • 4,989
  • 13
  • 52
  • 93
7
votes
1 answer

How to declare unlimited parameters in Laravel?

Is there any way to declare unlimited number of parameters in routes of Laravel 5 similar to Codeigniter? I am going to build a large application and declaring each and every parameter in route file for each function is not possible. I tried…
Nishant Kango
  • 146
  • 1
  • 9
7
votes
3 answers

simple Laravel View::make() not working

So I'm learning some basic Laravel stuff as I am new to PHP. I am following a basic tutorial that is having me print stuff to a file named home.blade.php. The way I am calling it now is as follows. Here is my routes.php Route::get('/', array( …
ryndshn
  • 692
  • 2
  • 13
  • 30
7
votes
5 answers

How to Add More than One Item to Middleware on Route in Laravel 5

I recently started using Laravel 5 and I'm having a lot of trouble implementing a system that not only authorizes users, but also checks permissions. In all of the examples I've dug up online, I see two items being applied as middleware. For…
Lucha Laura Hardie
  • 429
  • 1
  • 3
  • 10
7
votes
2 answers

Add url extensions to Laravel routes

Is it possible to add an extension to laravel routes like so? http://www.mywebsite.com/members/login.html and another page with a different extension http://www.mywebsite.com/contactus.htm I am transitioning an old website into laravel but the owner…
bman
  • 3,740
  • 9
  • 34
  • 40
6
votes
1 answer

how to use apiReources method with `only`?

I'm creating an api with Laravel and I am looking for an easy lazy way to to register Api resources. I'm currently defining my routes like this: Route::apiResource('categories', 'CategoryController')->only(['index', 'show']); I checked Laravel's…
RoduanKD
  • 1,279
  • 11
  • 27