Tarik Mokafih Tarik Mokafih - 2 years ago 142
PHP Question

Laravel : Method [show] does not exist

When trying to access this URL 'users/login' I got that error, Here is my code :

View users/login.blade.php :

<head>Sign in : </head>
{{ HTML::ul($errors->all()) }}
<?php echo Form::open(array('url' => 'users'));

echo '<div class="form-group">';
echo Form::label('username', 'User Name');
echo Form::text('ausername', null, array('class' => 'form-control'));
echo '</div>';

echo '<div class="form-group">';
echo Form::label('Password', 'Password');
echo Form::password('apassword', null, array('class' => 'form-control'));
echo '</div>';

echo Form::submit('Sign in', array('class' => 'btn btn-primary'));

echo Form::close();

Controller Usercontroller.php


class UserController extends BaseController {

public function index()
$users = User::all();
return View::make('users.index')
->with('users', $users);

public function create()
return View::make('users.create');

public function store()
$rules = array(
'username' => 'required|alpha_dash',
'password' => 'required|confirmed',
'name' => 'required|regex:/^[a-zA-Z][a-zA-Z ]*$/',
'email' => 'required|email|unique:users',
'country' => 'required'
$validator = Validator::make(Input::all(), $rules);

if ($validator->fails()) {
return Redirect::to('users/create')
} else {
$user = new User;
$user->username = Input::get('username');
$user->password = Hash::make(Input::get('password'));
$user->name = Input::get('name');
$user->email = Input::get('email');
$user->country = Input::get('country');
// redirect
Session::flash('message', 'Successfully created user!');
return Redirect::to('users');

public function login()
$reflector = new ReflectionClass("UserController");
$fn = $reflector->getFileName();
return View::make('users.login');

public function authen()
if (Auth::attempt(array('username' => Input::get('ausername'), 'password' => Input::get('apassword'))))
return Redirect::intended('users');


and my routes.php

Route::get('users/login', 'UserController@login');
Route::get('/', function()
return View::make('hello');

is it a route problem, thank you for the help

Answer Source

I have experienced the same problem as you. The problem ends up with rearranging the resource code, i.e.

Route::get('masterprices/data', 'MasterPriceController@data');
Route::get( 'masterprices/upload', 'MasterPriceController@upload');
Route::post('masterprices/upload', 'MasterPriceController@do_upload');
Route::get('masterprices/{masterprices}/multipledelete', 'MasterPriceController@multipledelete');
Route::resource('masterprices', 'MasterPriceController');

It checks the other possible handler, if none it will reach the last line which is resource to handle index page.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download