I have two Login forms which is for admin and User
Admin Login Form
{!! Form::open(array('url' => '/adminLogin', '', 'class'=>'form-vertical')) !!}
<div class="module-head">
<h3>Sign In</h3>
</div>
<div class="module-body">
<div class="control-group">
<div class="controls row-fluid">
<input class="span12" type="text" placeholder="Username" name="username" required>
</div>
</div>
<div class="control-group">
<div class="controls row-fluid">
<input class="span12" type="password" placeholder="Password" name="password" required>
</div>
</div>
</div>
<div class="module-foot">
<div class="control-group">
<div class="controls clearfix">
<button type="submit" class="btn btn-primary pull-right">Login</button>
</div>
</div>
</div>
{!! Form::close() !!}
User Login Form
{!! Form::open(array('url' => '/signin')) !!}
<div class="top-margin">
<label>Username <span class="text-danger">*</span></label>
<input type="text" class="form-control" name="username" required>
</div>
<div class="top-margin">
<label>Password <span class="text-danger">*</span></label>
<input type="password" class="form-control" name="password" required>
</div>
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<hr>
<div class="row">
<div class="col-lg-8">
</div>
<div class="col-lg-4 text-right">
<button class="btn btn-danger" type="submit">Sign in</button>
</div>
</div>
{!! Form::close() !!}
and this are my routes for Admin and User
Route::get('/signin', 'UserController@showSignIn');
Route::post('/signin', 'UserController@doLogin');
Route::get('/signup', 'UserController@showSignUp');
Route::post('/signup', 'UserController@signupUser');
Route::get('/logout', 'UserController@logout');
Route::post('/adminLogin', 'AdminController@adminLogin');
Route::get('/register', 'AdminController@showRegister');
Route::post('/register', 'AdminController@register');
Route::get('/doLogout', 'AdminController@logout');
my controller for Admin and User
public function adminLogin()
{
$data = Request::all();
$admin = array(
'username' => $data['username'],
'password' => $data['password']
);
if (Auth::attempt($admin)) {
/* Session::put('key', $data['username']);*/
return Redirect::to('/index')
->with('flash_error', 'Welcome')
->with('flash_color', '#27ae60');
}
return Redirect::back()
->with('flash_error', 'Invalid Credintials')
->with('flash_color', '#c0392b');
}
public function doLogin()
{
$data = Request::all();
$user = array(
'username' => $data['username'],
'password' => $data['password']
);
if (Auth::attempt($user)) {
Session::put('key', $data['username']);
return Redirect::to('/profile')
->with('flash_error', 'Welcome')
->with('flash_color', '#27ae60');
}
return Redirect::back()
->with('flash_error', 'Invalid Credintials')
->with('flash_color', '#c0392b');
}
and I have a two table for my database which is the Admin table and Users table..my problem is when I login to the Admin Form it validates the registered user to the Users Table.how can i solve this..so when I login to the admin form it validates only the admin table
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community