samedi 16 juin 2018

how to use post method i route in laravel 5.4

I am learning laravel 5.4 framework.

In web.php:

Route::post('/admin3','Admincontroller@postindex');

In Admincontroller:

<?php
namespace App\Http\Controllers;
use App\Customer;

class Admincontroller extends controller{

public function index()
{
    //echo"Index method";
    return view('Welcome');
}
public function postindex()
{
    echo"Index method";
    //return view('Welcome');
}
?>

When I run url admin3, then got error:

(1/1) MethodNotAllowedHttpException
in RouteCollection.php line 251
at RouteCollection->methodNotAllowed(array('POST'))
in RouteCollection.php line 238
at RouteCollection->getRouteForMethods(object(Request), array('POST'))
in RouteCollection.php line 176
at RouteCollection->match(object(Request))
in Router.php line 546

But when I use get method, it is working fine. But post is giving errors.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2lf7KPO
via IFTTT

Aucun commentaire:

Enregistrer un commentaire