laravel-routing

How to Get Current Route Name?

喜夏-厌秋 提交于 2019-11-26 18:12:36
In Laravel 4 I was able to get the current route name using... Route::currentRouteName() How can I do it in Laravel 5? Try this Route::getCurrentRoute()->getPath(); or \Request::route()->getName() from v5.+ use Illuminate\Support\Facades\Route; $currentPath= Route::getFacadeRoot()->current()->uri(); Laravel 5.3 Route::currentRouteName(); //use Illuminate\Support\Facades\Route; Or if you need the action name Route::getCurrentRoute()->getActionName(); You can find everything about laravel Routes in the Laravel API: http://laravel.com/api/5.0/Illuminate/Routing/Router.html http://laravel.com/api

Laravel 4 All Routes Except Home Result in 404 Error

陌路散爱 提交于 2019-11-26 07:29:56
问题 I installed Laravel 4 using Composer and also set up a virtual host. Currently, only the root route is working: <?php Route::get(\'/\', function() { return View::make(\'hello\'); }); This is not: Route::get(\'/hello\', function() { return View::make(\'hello\'); }); What I\'m trying to hit is TasksController at /tasks : Route::resource(\'tasks\', \'TasksController\'); This is giving me 404 error as well. What could I be doing wrong? I have a default .htaccess file at the root of my project:

Laravel: How to Get Current Route Name? (v5 & v6)

Deadly 提交于 2019-11-26 06:14:49
问题 In Laravel v4 I was able to get the current route name using... Route::currentRouteName() How can I do it in Laravel v5 and Laravel v6 ? 回答1: Try this Route::getCurrentRoute()->getPath(); or \Request::route()->getName() from v5.1 use Illuminate\Support\Facades\Route; $currentPath= Route::getFacadeRoot()->current()->uri(); Laravel v5.2 Route::currentRouteName(); //use Illuminate\Support\Facades\Route; Or if you need the action name Route::getCurrentRoute()->getActionName(); Laravel 5.2 route

How Can I Remove “public/index.php” in the URL Generated Laravel?

风流意气都作罢 提交于 2019-11-26 03:24:24
I need to remove index.php or public/index.php from the generated URL in Laravel; commonly path is localhost/public/index.php/someWordForRoute , It should be something like localhost/someWordForRoute. .htaccess <IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews </IfModule> RewriteEngine On # Redirect Trailing Slashes. RewriteRule ^(.*)/$ /$1 [L,R=301] # Handle Front Controller. RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php[L] app/config/app.php 'url' => 'http://localhost', How can I change that? Option 1: Use .htaccess If

Laravel 5 - redirect to HTTPS

一笑奈何 提交于 2019-11-26 03:22:17
问题 Working on my first Laravel 5 project and not sure where or how to place logic to force HTTPS on my app. The clincher here is that there are many domains pointing to the app and only two out of three use SSL (the third is a fallback domain, long story). So I\'d like to handle this in my app\'s logic rather than .htaccess. In Laravel 4.2 I accomplished the redirect with this code, located in filters.php : App::before(function($request) { if( ! Request::secure()) { return Redirect::secure

Laravel 5 - redirect to HTTPS

北城余情 提交于 2019-11-26 02:52:42
Working on my first Laravel 5 project and not sure where or how to place logic to force HTTPS on my app. The clincher here is that there are many domains pointing to the app and only two out of three use SSL (the third is a fallback domain, long story). So I'd like to handle this in my app's logic rather than .htaccess. In Laravel 4.2 I accomplished the redirect with this code, located in filters.php : App::before(function($request) { if( ! Request::secure()) { return Redirect::secure(Request::path()); } }); I'm thinking Middleware is where something like this should be implemented but I

How Can I Remove “public/index.php” in the URL Generated Laravel?

假如想象 提交于 2019-11-26 01:14:13
问题 I need to remove index.php or public/index.php from the generated URL in Laravel; commonly path is localhost/public/index.php/someWordForRoute , It should be something like localhost/someWordForRoute. .htaccess <IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews </IfModule> RewriteEngine On # Redirect Trailing Slashes. RewriteRule ^(.*)/$ /$1 [L,R=301] # Handle Front Controller. RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index