Reputation: 523
I am new to laravel and just tried some examples. This is:
laravel-master\app\controllers\account.php -
class AccountController extends BaseController
{
public function action_index()
{
echo "This is the profile page.";
}
public function action_login()
{
echo "This is the login form.";
}
public function action_logout()
{
echo "This is the logout action.";
}
}
Then i added one line at - laravel-master\app\routes.php
Route::controller('account');
So when i will go to the main page
but its showing
Missing argument 2 for Illuminate\Routing\Router::controller(), called in C:\Program Files\Zend\Apache2\htdocs\laravel-master\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php on line 177 and defined
.Don't know what is the problem . Am i wrong somewhere ?
Upvotes: 1
Views: 2901
Reputation: 1812
Change the name of the controller file to:
laravel-master\app\controllers\AccountController.php
Change the route definition to:
Route::controller('account', 'AccountController');
Change the controller methods to:
class AccountController extends BaseController
{
public function getIndex()
{
echo "This is the profile page.";
}
public function getLogin()
{
echo "This is the login form.";
}
public function getLogout()
{
echo "This is the logout action.";
}
}
Upvotes: 7
Reputation: 2126
Not a Laravel expert, but I think your Route::controller
is missing an argument for the destination of the route and you should use the full name of the controller class. Try
Route::controller('account', 'AccountController')
I am also not sure about the action_
s. If I understand the documentation on controllers correctly, they have to be prefixed with an HTTP verb, e.g.
public function getIndex()
instead of
public function action_index()
Upvotes: 1