How to route GET and POST for same pattern in Laravel?

前端 未结 10 1914
余生分开走
余生分开走 2020-12-24 10:55

Does anyone know of any way in Laravel 4 which combines these 2 lines into one?

Route::get(\'login\', \'AuthControl         


        
相关标签:
10条回答
  • 2020-12-24 11:44

    As per the latest docs, it should be

    Route::match(['get', 'post'], '/', function () {
        //
    });
    

    https://laravel.com/docs/routing

    0 讨论(0)
  • 2020-12-24 11:45
    Route::match(array('GET', 'POST', 'PUT'), "/", array(
        'uses' => 'Controller@index',
        'as' => 'index'
    ));
    
    0 讨论(0)
  • 2020-12-24 11:50

    The docs say...

    Route::match(array('GET', 'POST'), '/', function()
    {
        return 'Hello World';
    });
    

    source: http://laravel.com/docs/routing

    0 讨论(0)
  • 2020-12-24 11:58

    Right, I'm answering using my mobile, and so I haven't tested this (if I remember correctly, it isn't in the documentation either). Here goes:

    Route::match('(GET|POST)', 'login',
        'AuthController@login'
    );
    

    That should do the trick. If it doesn't, then Taylor had it removed from the core; which would then mean that nobody was using it.

    0 讨论(0)
提交回复
热议问题