I am new in Larave and I made a login form that not working, I searched a lot about this problem and I found these questions and answers that not working for me:
I read these 3 questions and again not working:
This is my users table:
id | username | password | remember_token | created_at | updated_at
1 | [email protected]| testpass1
This is my User Model:
<?php
use Illuminate\Auth\UserTrait;
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableTrait;
use Illuminate\Auth\Reminders\RemindableInterface;
class User extends Eloquent implements UserInterface, RemindableInterface {
use UserTrait, RemindableTrait;
public static $auth_rules=[
'email'=>'required|email',
'password'=>'required|between:3,18'
];
protected $hidden = array('password', 'remember_token');
}
This is my route:
Route::group(array('prefix'=>'admin','before'=>'Auth'),function(){
Route::resource('posts','AdminPostsController', array('except'=>array('show')));
});
This is Filter(Auth):
Route::filter('Auth', function()
{
if (Auth::guest())
{
if (Request::ajax())
{
return Response::make('Unauthorized', 401);
}
else
{
return Redirect::guest('admin/login');
}
}
});
and this is AdminAuthController that route send data from login to AdminAuthController@postLogin:
//This is postLogin method:
public function postLogin(){
//Showing username and password
echo 'Username:'.Input::get('email').'<br/>';
echo 'Password:'.Input::get('password').'<br />';
//If username and password: return true
dd(Auth::attempt(array('username'=>Input::get('email'),'password'=>Input::get('password') )));
}
This is what Laravel return in browser: http://i.stack.imgur.com/9cq61.png