Pregunta

How can task accomplished with the verb restful in Laravel, What is basic function ?

¿Fue útil?

Solución

Please read the Laravel documentation before posting such a basic question.

Instead of prefixing controller actions with "action_", you may prefix them with the HTTP verb they should respond to.

This means your function 'respond' to the command given - i.e. GET, POST, PUT, DELETE. So a non-restful controller will have:

public function action_login()
{
    if ($_POST)
    {
       // Try and login user
    }
    else
    {
       // Show login form
    }
}

But a restful controller would be:

public function post_login()
{
       // Try and login user
}

public function get_login()
{
       // Show login form
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top