laravel-routing

Laravel Queries Strings

99封情书 提交于 2019-12-17 11:42:24
问题 Does anyone know if it's possible to make use of URL query's within Laravel. Example I have the following route: Route::get('/text', 'TextController@index'); And the text on that page is based on the following url query: http://example.com/text?color={COLOR} How would I approach this within Laravel? 回答1: Yes, it is possible. Try this: Route::get('test', function(){ return "<h1>" . Input::get("color") . "</h1>"; }); and call it by going to http://example.com/test?color=red . You can, of course

Laravel Controller Subfolder routing

你说的曾经没有我的故事 提交于 2019-12-17 07:05:29
问题 I'm new to Laravel. To try and keep my app organized I would like to put my controllers into subfolders of the controller folder. controllers\ ---- folder1 ---- folder2 I tried to route to a controller, but laravel doesn't find it. Route::get('/product/dashboard', 'folder1.MakeDashboardController@showDashboard'); What am I doing wrong? 回答1: 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

Laravel Controller Subfolder routing

坚强是说给别人听的谎言 提交于 2019-12-17 07:04:05
问题 I'm new to Laravel. To try and keep my app organized I would like to put my controllers into subfolders of the controller folder. controllers\ ---- folder1 ---- folder2 I tried to route to a controller, but laravel doesn't find it. Route::get('/product/dashboard', 'folder1.MakeDashboardController@showDashboard'); What am I doing wrong? 回答1: 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

Download files in laravel using Response::download

最后都变了- 提交于 2019-12-17 04:45:14
问题 In Laravel application I'm trying to achieve a button inside view that can allow user to download file without navigating to any other view or route Now I have two issues: (1) below function throwing The file "/public/download/info.pdf" does not exist (2) Download button should not navigate user to anywhere and rather just download files on a same view, My current settings, routing a view to '/download' Here is how Im trying to achieve: Button: <a href="/download" class="btn btn-large pull

How can i access this multi URL in laravel 4?

你说的曾经没有我的故事 提交于 2019-12-13 22:15:34
问题 How can i access this multi URL in laravel 4.2. http://localhost/new/public/library/course/1/First%20Video My code is Route::get('library/course/{id}', function($id){ return View::make('course')->with('id',$id); }); Route::get('library/course/{id}/{video}', function($id, $video){ $array = array('id' => '$id', 'video' => '$video'); return View::make('course')->withvideos($array); }); 回答1: You are accessing the URL correctly, and it should reach your second route. But you have a bug in your

How to put controller inside folder in laravel 5.1.3?

前提是你 提交于 2019-12-13 17:12:15
问题 I am new to laravel. I am trying to organise my controller by putting it inside a folder, but it doesn't seem to work. My folder structure is like this: /app /Http /Controllers /Admin ShowDashboard.php My ShowDashboard.php file is like this: <?php namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; class ShowDashboard extends Controller { /** * Show the profile for the given user. * * @param int $id * @return Response */ public function init() { return 'Hi there!'; } }

Prefix route name without prefixing URI in Laravel

久未见 提交于 2019-12-13 16:02:03
问题 I have two namespaces 'Front' and 'Admin' . For 'Admin' namespace it is OK to have all paths prefixed with admin.conrtoller.action , but for 'Front' I want to have prefixed route names without prefixed URIs. Route::group(array('namespace' => 'Front'), function() { Route::resource('franchising', 'FranchisingController', array('only' => array('index'))); }); This generates me franchising.index root name and get 'franchising' URI. How to make all resources in this group to generate route names

link to specific anchor on a page with Laravel

[亡魂溺海] 提交于 2019-12-13 14:08:41
问题 How does one go about linking to a specific id in a view with Laravel? My controller: public function services() { return View::make('services.custom_paint', array('pageTitle' => 'Custom Paint'))->with('default_title', $this->default_title); } My route: Route::get('/custom_paint', 'PagesController@services'); I have tried to add #id to the route, to the controller, and even to the view's URL::to . Nothing seems to work. I assumed that simply adding the id on to the URI would do the trick, but

Laravel download file from S3 route (not open in browser)

痞子三分冷 提交于 2019-12-13 07:41:15
问题 I have the following route that will load a file from the given URL, I need this to actually download the file (mp4, jpg, pdf) rather than open in the browsers in built viewer. // Download from CDN Route Route::get('cdn/{url}', function($url) { return Redirect::away($url); })->where('url', '(.*)'); All files are stored externally so apparently Resource::download() wouldn't actually work. All I have available to me is the Amazon URL: https://mybucket.s3.amazonaws.com/folder/filename.pdf Any

Laravel Redirect::intended() conditional fallbacks

删除回忆录丶 提交于 2019-12-13 06:50:00
问题 To my understanding, Redirect::intended() will redirect to a users intended page prior to logging in, or fall back to a url that can be passed as an argument. My question is this: How would I make it so that it first checks if there is an intended url in the session, if not it does a Redirect::back() instead, and if that fails it will redirect to the users profile which would be the same as Redirect::route('users.show', Auth::user()->username); 回答1: Notes: Partially, the behavior you expected