laravel-routing

Reset user passwords in Laravel framework

偶尔善良 提交于 2020-01-17 12:28:05
问题 I'm trying to implement the password reminder according to this: http://laravel.com/docs/4.2/security I used the artisan commands : php artisan auth:reminders-table php artisan migrate and added this to my routes: Route::controller('password', 'RemindersController'); Route::get('forgotpassword', 'RemindersController@getRemind'); so now when I go to this page : myapp/forgotpassword I get the password.remind view which has the following code: <?php include_once(app_path()."/includes/header.php"

laravel 4 - pull similar data in multiple controllers into many views

余生颓废 提交于 2020-01-17 05:19:15
问题 I have users routes like that: user/13/posts/10 user/13/videos/443 user/13/items/4002 And i want to pull all the data related to 'user/13' every time posts/videos/items views are loaded. i am also loading the sidebar @include('inc/blog-sidebar') and this file contain data that is the same in all the views and related to 'user/13'. what is the best way to pull all this information without doing it per function within every controller? I have tried view:composer within the routes.php (which is

Multiple routes defaults to controller in Laravel

陌路散爱 提交于 2020-01-16 18:42:53
问题 I want to be able to get to an article by a short-link, like this articles/ID , but I also want to get there with the full link articles/ID/category/slug . But I can not get the following to work: // Route file: Route::pattern('id', '[0-9]+'); Route::pattern('cat', '^(?!create).*'); Route::pattern('slug', '^(?!edit).*'); Route::get('articles/{id}/{cat?}/{slug?}', ['as' => 'articles.show', 'uses' => 'ArticlesController@show']); // Controller file: public function show($id, $cat = null, $slug =

Multiple routes defaults to controller in Laravel

≡放荡痞女 提交于 2020-01-16 18:42:11
问题 I want to be able to get to an article by a short-link, like this articles/ID , but I also want to get there with the full link articles/ID/category/slug . But I can not get the following to work: // Route file: Route::pattern('id', '[0-9]+'); Route::pattern('cat', '^(?!create).*'); Route::pattern('slug', '^(?!edit).*'); Route::get('articles/{id}/{cat?}/{slug?}', ['as' => 'articles.show', 'uses' => 'ArticlesController@show']); // Controller file: public function show($id, $cat = null, $slug =

Laravel - regex route match everything but not exactly one or more word

眉间皱痕 提交于 2020-01-14 07:27:08
问题 I make a route like Route::get('/{url1}', function ($url1) { return ' url1: '.$url1; }) ->where('url1', '^(?!(string1|string2)$)'); and access url like: - domain/abc not found => incorrect ?? - domain/string1 not found => correct and more, when i do with Route::get('/{url1}/{url2}', function ($url1) { return ' url1: '.$url1; }) ->where('url1', '^(?!(string1|string2)$)'); and access url like: - domain/abc/abc not found => incorrect ??? - domain/string1/abc not found => correct How to fix that

Laravel 4 Route issues with multiple and optional get params

China☆狼群 提交于 2020-01-14 03:35:34
问题 I am creating a webservice with Laravel 4 and I am facing an issue with Optional params. Consider scenario below:: http://webservices.example.com/city/mumbai/q/hospital/ Which renders results for a search page with few filters e.g. category and location and ofcourse params for pagination too. Now these Filter params may be optional and may not have a pre-defined order coz it depends on how user might select filters. So lets say following URL forms are possible http://webservices.example.com

How to declare unlimited parameters in Laravel?

廉价感情. 提交于 2020-01-12 18:51:31
问题 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 searching a lot but didn't got any solution. 回答1: You can use this //routes.php Route::get('{id}/{params?}', 'YourController@action')->where('params', '(.*)'); Remember to put the above on the very end (bottom) of routes.php file as it is like a 'catch

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

血红的双手。 提交于 2020-01-11 02:32:48
问题 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 Laravel, to have a single rule which caters for an unknown number of levels in the book structure (similar to this question)? This would mean where there are sub-articles, sub-sub-articles, etc.. 回答1: What you need are optional routing parameters: //in

MethodNotAllowedHttpException thrown after user logs in and get redirected

不打扰是莪最后的温柔 提交于 2020-01-06 19:49:08
问题 Was testing around and this is the behaviour: I have a page with a form, anyone can use it (no need to be logged in), when submitting you get redirected to the next one for which you need to be logged in as a user. Here is the route: /* | Request Booking (POST) */ Route::post('/booking/request-pay-booking', array( 'as' => 'booking-request-pay-booking-post', 'uses' => 'BookingController@postRequestPayBooking' )); Everything works as long as you are already logged in BEFORE. If you are public

Using @ (at sign) in PHP Laravel strings

核能气质少年 提交于 2020-01-06 02:44:21
问题 I have the below code in my app. The problem is the @ (at sign). When it's there, I get syntax highlighting and errors as if the string doesn't end. When remove it, the page works fine (minus the action not existing). I've tried escaping the @ and that doesn't work. I've also tried double quotes, but that doesn't work either. How can I escape @? I could use the route function and avoid the @ entirely but I feel that the action function is far more clear in terms of what it's doing so I'd