laravel-routing

handle multiple post requests to same url Laravel 5

喜欢而已 提交于 2019-12-02 05:57:46
I have two forms on a page both submits the data via POST method . I want to handle both requests on the same url i.e /home and use different controllers and methods for both forms. Below are the two routes. Route::post('home' ,'FacebookControllers\PostsController@save'); Route::post('home' , 'FacebookControllers\MessageController@storeMessage'); In PostsController@save I am checking if(isset($_POST['submitPost']) && $_SERVER['REQUEST_METHOD']=='POST'){ //do something } and in MessageController@storeMessage I am doing the same for other form if(isset($_POST['sendMessage']) && $_SERVER['REQUEST

Laravel 5 HTTP/Requests - pass url parameter to the rules() method

帅比萌擦擦* 提交于 2019-12-02 04:25:31
I'm trying to create a set of rules under the new \HTTP\Requests\UpdateArticle class for the slug field, which needs to have unique filter applied, but only when the id is not equal the url parameter of the route name article/{article} . What I got so far is: public function rules() { return [ 'title' => 'required|min:3', 'excerpt' => 'required', 'body' => 'required', 'slug' => 'required|unique:articles,slug,?', 'active' => 'required', 'published_at' => 'required|date' ]; } I need to replace the question mark at the end of the unique filter for slug field with the id from the url, but don't

Laravel 5 : [Call to a member function getAction() on a non-object

前提是你 提交于 2019-12-02 01:12:46
In my Controller, I have Route::getCurrentRoute()->getAction()['as'] Everything works well in the browser but as soon as I type php artisan route:list in the terminal I have this exception [Symfony\Component\Debug\Exception\FatalErrorException] Call to a member function getAction() on a non-object If I comment this line everything works well. Seems obvious doesn't it? Get current route in a browser will return the currently visited route. In the terminal you do not have such a request. Laravel will return null when asking what route is visited. You would have to check for the return value

Can I use Laravel 5 Middleware to allow packages to override app routes?

跟風遠走 提交于 2019-12-01 19:56:44
问题 I would like to be able to override the routes defined in app/Http/routes.php with a route in a package. For example, in app/Http/routes.php I might have this: Route::get('/search/{type?}',['as' => 'search','uses' => 'SearchController@search']); I want to be able to define this in /vendor/author/package/src/Http/routes.php: Route::get('/search/properties', ['as' => 'properties','uses' => 'PropertyController@search']); The app/Http/routes.php file is loaded first so the route in their is used,

Can I use Laravel 5 Middleware to allow packages to override app routes?

二次信任 提交于 2019-12-01 18:01:40
I would like to be able to override the routes defined in app/Http/routes.php with a route in a package. For example, in app/Http/routes.php I might have this: Route::get('/search/{type?}',['as' => 'search','uses' => 'SearchController@search']); I want to be able to define this in /vendor/author/package/src/Http/routes.php: Route::get('/search/properties', ['as' => 'properties','uses' => 'PropertyController@search']); The app/Http/routes.php file is loaded first so the route in their is used, not the package. In Laravel 4 I would do this using App::before or App::after, giving them a priority.

How can I do variable/wildcard routes in Laravel?

陌路散爱 提交于 2019-12-01 17:46:50
I am using Laravel 5 and need to do a wildcard route, sending the user to different controllers based on the URL type, pulled in from the database. I need to check the URL slug in the database, and then load the relevant controller/method based on the slug type, held in the database. I am struggling with the final part, which is sending the user to the relevant controller. Below is my route: Route::any('{slug}', function($slug){ $url = \App\Url_slug::where('url_slug', $slug)->first(); if($url->count()){ switch($url->url_type){ case 'product': // SEND USER TO PRODUCT CONTROLLER break; case

How can I do variable/wildcard routes in Laravel?

落花浮王杯 提交于 2019-12-01 17:41:01
问题 I am using Laravel 5 and need to do a wildcard route, sending the user to different controllers based on the URL type, pulled in from the database. I need to check the URL slug in the database, and then load the relevant controller/method based on the slug type, held in the database. I am struggling with the final part, which is sending the user to the relevant controller. Below is my route: Route::any('{slug}', function($slug){ $url = \App\Url_slug::where('url_slug', $slug)->first(); if($url

How to apply multiple filters on route group in Laravel 4?

雨燕双飞 提交于 2019-12-01 13:59:52
Goal : I want to make route filter in Laravel 4 using Route::group and Route::filter Description I have 2 types of user : Internal Distributor For, Internal , I have 2 groups: admin regular For Distributor , I have 4 groups: gold silver bronze oem Eligible Route OEM Distributor are eligible for only 5 routes. Route::get('distributors/{id}', array('before' =>'profile', 'uses'=>'DistributorController@show')); Route::get('distributors/{id}/edit', 'DistributorController@edit'); Route::put('distributors/{id}/update', array('as'=>'distributors.update', 'uses'=>'DistributorController@update')); Route

How to apply multiple filters on route group in Laravel 4?

守給你的承諾、 提交于 2019-12-01 12:58:27
问题 Goal : I want to make route filter in Laravel 4 using Route::group and Route::filter Description I have 2 types of user : Internal Distributor For, Internal , I have 2 groups: admin regular For Distributor , I have 4 groups: gold silver bronze oem Eligible Route OEM Distributor are eligible for only 5 routes. Route::get('distributors/{id}', array('before' =>'profile', 'uses'=>'DistributorController@show')); Route::get('distributors/{id}/edit', 'DistributorController@edit'); Route::put(

Laravel - Routes GET|HEAD

我的梦境 提交于 2019-12-01 10:33:53
问题 When I do php artisan routes , the GET request of my app has a |HEAD . What is the purpose of having |HEAD ? Routes.php +--------+----------------------------------+------------------------------+--------------------------------------+----------------+---------------+ | Domain | URI | Name | Action | Before Filters | After Filters | +--------+----------------------------------+------------------------------+--------------------------------------+----------------+---------------+ | | GET|HEAD