Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use IlluminateDatabaseSchemaBlueprint;
- use IlluminateDatabaseMigrationsMigration;
- class AdminDetails extends Migration
- {
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- Schema::create('admin_details', function (Blueprint $table) {
- $table->increments('id');
- $table->string('name');
- $table->string('username')->unique();
- $table->string('email')->unique();
- $table->string('password', 60);
- $table->integer('status');
- $table->rememberToken();
- $table->timestamps();
- });
- }
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::drop('admin_details');
- }
- }
- <form name="frmLogin" action="{{ URL::to('administrator/userAuthentication') }}" method="post">
- <input name="_token" type="hidden" value="{{ csrf_token() }}"/>
- <div class="form-group has-feedback">
- <input type="text" name="username" id="username"class="form-control" placeholder="Username">
- <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
- </div>
- <div class="form-group has-feedback">
- <input type="password" name="password" id="password" class="form-control" placeholder="Password">
- <span class="glyphicon glyphicon-lock form-control-feedback"></span>
- </div>
- <div class="row">
- <div class="col-xs-4">
- <button type="submit" class="btn btn-primary btn-block btn-flat">Login</button>
- </div><!-- /.col -->
- </div>
- </form>
- <?php
- namespace AppHttpControllers;
- use IlluminateHttpRequest;
- use AppHttpRequests;
- use Auth;
- use AppHttpControllersController;
- use AppAdminLoginModel;
- class AdminLoginController extends Controller
- {
- /**
- * Display a listing of the resource.
- *
- * @return Response
- */
- public function index()
- {
- return view('backend.login');
- }
- /**
- * Handle an authentication attempt for admin user.
- *
- */
- public function userAuthentication(Request $request)
- {
- if (Auth::attempt(array('username' => $request->username, 'password' => $request->password))){
- return "success";
- }else{
- return "Wrong Credentials";
- }
- die;
- }
- }
- <?php
- /*namespace App;
- use DB;
- use IlluminateDatabaseEloquentModel;*/
- namespace App;
- use IlluminateAuthAuthenticatable;
- use IlluminateDatabaseEloquentModel;
- use IlluminateAuthPasswordsCanResetPassword;
- use IlluminateContractsAuthAuthenticatable as AuthenticatableContract;
- use IlluminateContractsAuthCanResetPassword as CanResetPasswordContract;
- class AdminLoginModel extends Model implements AuthenticatableContract, CanResetPasswordContract
- {
- use Authenticatable, CanResetPassword;
- protected $table = 'admin_details';
- protected $fillable = ['username', 'password'];
- }
- <?php
- /*
- |--------------------------------------------------------------------------
- | Application Routes
- |--------------------------------------------------------------------------
- |
- | Here is where you can register all of the routes for an application.
- | It's a breeze. Simply tell Laravel the URIs it should respond to
- | and give it the controller to call when that URI is requested.
- |
- */
- Route::get('/', function () {
- return view('welcome');
- });
- Route::resource('dashboard','DashboardController');
- Route::resource('administrator','AdminLoginController');
- Route::resource('users','AdminLoginController');
- Route::resource('administrator/userAuthentication', 'AdminLoginController@userAuthentication');
- <!DOCTYPE html>
- <html>
- <head>
- <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
- </head>
- <body>
- <div class="container">
- <h3>Login Form</h3>
- {!! Form::open(array('url' => 'login', 'method' => 'post')) !!}
- <div class="form-group">
- {!! Form::label('UserName') !!}
- {!! Form::text('username', null,
- array(
- 'class'=>'form-control',
- 'placeholder'=>'Your UserName')) !!}
- </div>
- <div class="form-group">
- {!! Form::label('password') !!}
- {!! Form::text('password', null,
- array(
- 'class'=>'form-control',
- 'placeholder'=>'Your Password')) !!}
- </div>
- <div class="form-group">
- {!! Form::submit('Login',
- array('class'=>'btn btn-primary')) !!}
- </div>
- {!! Form::close() !!}
- </div>
- </body>
- </html>
- <?php namespace App;
- use IlluminateAuthAuthenticatable;
- use IlluminateDatabaseEloquentModel;
- use IlluminateAuthPasswordsCanResetPassword;
- use IlluminateContractsAuthAuthenticatable as AuthenticatableContract;
- use IlluminateContractsAuthCanResetPassword as CanResetPasswordContract;
- class UserRegisters extends Model implements AuthenticatableContract, CanResetPasswordContract {
- use Authenticatable, CanResetPassword;
- protected $table = 'userregisters';
- protected $fillable = ['user_name', 'password'];
- }
- ?>
- <?php namespace AppHttpControllers;
- use Input;
- use AppHttpRequests;
- use AppUser;
- use AppUserRegisters;
- use AppUserProfiles;
- use Validator;
- use View;
- use Auth;
- use AppHttpControllersRedirect;
- use Session;
- use Hash;
- use DB;
- class UserRegisterController extends Controller
- {
- /**
- * Login a Registered Users.
- *
- */
- public function login(){
- $uname = Input::get('username');
- $password = Input::get('password');
- if (Auth::attempt(array('user_name' => $uname, 'password' => $password))){
- return "success";
- }
- else {
- return "Wrong Credentials";
- }
- }
- }
- }
- Route::post('/login', 'UserRegisterController@login');
- <?php
- use IlluminateDatabaseSchemaBlueprint;
- use IlluminateDatabaseMigrationsMigration;
- class Userregisters extends Migration
- {
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- Schema::create('userregisters', function($table)
- {
- $table->increments('id');
- $table->string('first_name', 128);
- $table->string('last_name', 128);
- $table->string('user_name', 128);
- $table->string('password', 128);
- $table->string('email', 128);
- $table->timestamps();
- });
- }
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::drop('userregisters');
- }
- }
- $email=$request->email;
- $password=$request->password;
- if(Auth::attempt(['email'=>$email,'password'=>$password]))
- {
- return redirect()->intended('admin/dashboard');
- }
- id|username|password|email|remember_token|created_at|updated_at
- protected $table = 'users';
- protected $fillable = ['username', 'email', 'password'];
- public function loginPost(Request $request)
- {
- $email=$request->email;
- $password=$request->password;
- if(Auth::attempt(['email'=>$email,'password'=>$password]))
- {
- return redirect()->intended('admin/dashboard');
- }
- return Redirect::to('login');
- }
- $data=[];
- $data['email']=$request->email;
- $data['password']=Hash::make($password);
- User::create($data);
- public function insert()
- {
- $data=[];
- $data['email']=$request->email;
- $data['password']=Hash::make($password);
- AdminLoginModel::create($data);
- }
Add Comment
Please, Sign In to add comment