I am currently just testing laravel 4, but i have a problem, in the laravel docs returning error messages is described this way $messages->first('email');should return the message, but no matter what methog id try on the messages i get error
my cobtroller
public function postSignup()
{
$rules = array(
'display_name' => 'required|unique:users',
);
$messages = array(
'display_name.required' => 'Felhasználónév kötelező',
'display_name.unique' => 'Ez a Felhasználónév foglalt',
);
$val = Validator::make(Input::all(), $rules, $messages);
if ($val->passes())
{
$data = array('msg' => 'yay');
}
else
{
print_r($messages->first('display_name'));
}
return Response::json($data);
}
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Call to a member function first() on a non-object"
if i try with all just for a test print_r($messages->all()); im getting the following
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Call to a member function all() on a non-object"
could please someone point out what i am doing wrong?