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

Redirect to Login if user not logged in Laravel

i am new to laravel, i have code in my controller's __construct like if(Auth::check()) { return View::make('view_page'); } return Redirect::route('login')->withInput()->with('errmessage', 'Please Login to access restricted area.'); its…
rkaartikeyan
  • 1,977
  • 9
  • 29
  • 57
21
votes
3 answers

Laravel Update Syntax - Updating Record with Array

I'm having trouble doing a basic record update via POST in Laravel. I have captured all the post data in an array, and if the existing Order# is 0, then I create a new record (works fine). Otherwise I update the existing record. Order.php class…
jamis0n
  • 3,610
  • 8
  • 34
  • 50
20
votes
4 answers

Redirect to homepage if route doesnt exist in Laravel 5

/** Redirect 404's to home *****************************************/ App::missing(function($exception) { // return Response::view('errors.missing', array(), 404); return Redirect::to('/'); }); I have this code in my routes.php file. I am…
justin.esders
  • 1,316
  • 4
  • 12
  • 28
18
votes
2 answers

Upgrading to Laravel 5.2 invalidates all sessions

Upgrading from Laravel 5.1.17 to 5.2. My config/auth.php originally contained: 'driver' => 'eloquent', 'model' => 'Project\User', 'table' => 'users', New file is the same as the default, except with the updated namespace. 'defaults' => [ …
andrewtweber
  • 24,520
  • 22
  • 88
  • 110
18
votes
5 answers

Laravel route pass variable to controller

How do I pass a hard coded variable to a controller? My route is: Route::group(array('prefix' => $locale), function() { Route::get('/milk', array('as' => 'milk', 'uses' => 'ProductsController@index')); }); I want to do something…
imperium2335
  • 23,402
  • 38
  • 111
  • 190
18
votes
9 answers

Routes not working without index.php

Im using laravel 4. I have a view nest.blade.php and the corresponding controller NestController.php: Controller content: class NestController extends BaseController { public function showView() { return View::make('nest'); …
RSM
  • 14,540
  • 34
  • 97
  • 144
17
votes
4 answers

Undefined class constant 'App\Providers\RouteServiceProvider::HOME'

After upgrading the laravel 5.8 to laravel 6.x I am getting this error: Undefined class constant 'App\Providers\RouteServiceProvider::HOME' Before upgrading the application login system was the custom. After upgrading to laravel 6.x I want to use…
17
votes
1 answer

What does "as" keyword mean in Laravel routing?

As I understand from the Laravel documentation, it's used for redirection, but maybe I'm wrong. I wrote Route::get('user/profile', ['as' => 'profile', function () { echo 'some_text'; }]); then I was expecting my URL to redirect…
Aniket Singh
  • 2,464
  • 1
  • 21
  • 32
17
votes
3 answers

debugging laravel artisan from PHPStorm with homestead

I setup Laravel Homestead. I then configured both homestead xdebug.ini and PHPStorm to make the debugging work. Here is my xdebug.ini inside homestead zend_extension=xdebug.so xdebug.remote_autostart = on xdebug.remote_enable =…
user391986
  • 29,536
  • 39
  • 126
  • 205
16
votes
3 answers

whats the difference between fillable and guard in laravel?

I am newbie in Laravel and want to understand this with example. what are main difference between fillable and guard in laravel? How those are differentiated? Please share one basic example.
stephenn
  • 171
  • 1
  • 1
  • 3
16
votes
1 answer

Using Named URL in blade template

In Django, I can do this: Account Link which would give me domain/account/login where I have that URL named in my urls.py url(r'^account/login/$', views.Login.as_view(), name='account_login'), I want to do…
KhoPhi
  • 9,660
  • 17
  • 77
  • 128
16
votes
9 answers

Laravel htaccess

I've setup a new install of Laravel on my local. It appears there are issues with htaccess or Apache settings. I've researched for a number of hours and tried everything I read. OSX Lion 10.7.5 MAMP 3.0.5 PHP 5.5.10 mod_rewrite is being…
Alexnl
  • 397
  • 1
  • 3
  • 12
16
votes
2 answers

Laravel 4 defining RESTful controllers

So I'm new to the Laravel framework as of v4 and wondering what is the way to create and use RESTful controllers. Reading through the documentation, I'm a bit confused as to the difference between RESTful controllers and Resource controllers. When…
Iain
  • 1,724
  • 6
  • 23
  • 39
15
votes
1 answer

Location of PHP error logs in Laravel Homestead

I'm currently experiencing routing issues, where various pages of my application are returning white pages. Where are the PHP logs located within Homestead Vagrant so I can diagnose what's the issue? I've checked /var/log/ and I can only see a…
user860511
15
votes
1 answer

How to prevent Laravel Routes from being accessed directly (i.e. non-ajax requests)

In my project, I am using Laravel purely as a backend api and all frontend is handled by Angular javascript. At the moment, the Laravel routes can be accessed directly and it will cough out all the data in Json that shows in the browser. I want to…
Neel
  • 9,352
  • 23
  • 87
  • 128