How to get a list of registered route paths in Laravel?

Route::getRoutes() returns a RouteCollection. On each element, you can do a simple $route->getPath() to get path of the current route. Each protected parameter can be get with a standard getter. Looping works like this: $routeCollection = Illuminate\Support\Facades\Route::getRoutes(); foreach ($routeCollection as $value) { echo $value->getPath(); }

Download files in laravel using Response::download

Try this. public function getDownload() { //PDF file is stored under project/public/download/info.pdf $file= public_path(). “/download/info.pdf”; $headers = array( ‘Content-Type: application/pdf’, ); return Response::download($file, ‘filename.pdf’, $headers); } “./download/info.pdf”will not work as you have to give full physical path. Update 20/05/2016 Laravel 5, 5.1, 5.2 or 5.* users can use the following method instead of Response facade. … Read more

Laravel Controller Subfolder routing

For Laravel 5.3 above: php artisan make:controller test/TestController This will create the test folder if it does not exist, then creates TestController inside. TestController will look like this: <?php namespace App\Http\Controllers\test; use Illuminate\Http\Request; use App\Http\Controllers\Controller; class TestController extends Controller { public function getTest() { return “Yes”; } } You can then register your route this … Read more

Laravel 5 – redirect to HTTPS

You can make it works with a Middleware class. Let me give you an idea. namespace MyApp\Http\Middleware; use Closure; use Illuminate\Support\Facades\App; class HttpsProtocol { public function handle($request, Closure $next) { if (!$request->secure() && App::environment() === ‘production’) { return redirect()->secure($request->getRequestUri()); } return $next($request); } } Then, apply this middleware to every request adding setting the rule … Read more

Error “Target class controller does not exist” when using Laravel 8

You are using Laravel 8. In a fresh install of Laravel 8, there is no namespace prefix being applied to your route groups that your routes are loaded into. “In previous releases of Laravel, the RouteServiceProvider contained a $namespace property. This property’s value would automatically be prefixed onto controller route definitions and calls to the … Read more

Laravel: How to Get Current Route Name? (v5 … v7)

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 documentation Retrieving The Request URI The path method returns the request’s URI. So, if the incoming request is targeted at http://example.com/foo/bar, the path method will return foo/bar: $uri … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)