Guest User

Untitled

a guest
Sep 21st, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.38 KB | None | 0 0
  1. <?php
  2.  
  3. use IlluminateDatabaseSchemaBlueprint;
  4. use IlluminateDatabaseMigrationsMigration;
  5.  
  6. class AdminDetails extends Migration
  7. {
  8. /**
  9. * Run the migrations.
  10. *
  11. * @return void
  12. */
  13. public function up()
  14. {
  15. Schema::create('admin_details', function (Blueprint $table) {
  16. $table->increments('id');
  17. $table->string('name');
  18. $table->string('username')->unique();
  19. $table->string('email')->unique();
  20. $table->string('password', 60);
  21. $table->integer('status');
  22. $table->rememberToken();
  23. $table->timestamps();
  24. });
  25. }
  26.  
  27. /**
  28. * Reverse the migrations.
  29. *
  30. * @return void
  31. */
  32. public function down()
  33. {
  34. Schema::drop('admin_details');
  35. }
  36. }
  37.  
  38. <form name="frmLogin" action="{{ URL::to('administrator/userAuthentication') }}" method="post">
  39. <input name="_token" type="hidden" value="{{ csrf_token() }}"/>
  40. <div class="form-group has-feedback">
  41. <input type="text" name="username" id="username"class="form-control" placeholder="Username">
  42. <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
  43. </div>
  44. <div class="form-group has-feedback">
  45. <input type="password" name="password" id="password" class="form-control" placeholder="Password">
  46. <span class="glyphicon glyphicon-lock form-control-feedback"></span>
  47. </div>
  48. <div class="row">
  49. <div class="col-xs-4">
  50. <button type="submit" class="btn btn-primary btn-block btn-flat">Login</button>
  51. </div><!-- /.col -->
  52. </div>
  53. </form>
  54.  
  55. <?php
  56.  
  57. namespace AppHttpControllers;
  58. use IlluminateHttpRequest;
  59. use AppHttpRequests;
  60. use Auth;
  61. use AppHttpControllersController;
  62. use AppAdminLoginModel;
  63.  
  64.  
  65. class AdminLoginController extends Controller
  66. {
  67. /**
  68. * Display a listing of the resource.
  69. *
  70. * @return Response
  71. */
  72. public function index()
  73. {
  74. return view('backend.login');
  75. }
  76.  
  77. /**
  78. * Handle an authentication attempt for admin user.
  79. *
  80. */
  81. public function userAuthentication(Request $request)
  82. {
  83.  
  84. if (Auth::attempt(array('username' => $request->username, 'password' => $request->password))){
  85. return "success";
  86. }else{
  87. return "Wrong Credentials";
  88. }
  89. die;
  90. }
  91. }
  92.  
  93. <?php
  94. /*namespace App;
  95. use DB;
  96. use IlluminateDatabaseEloquentModel;*/
  97.  
  98. namespace App;
  99.  
  100. use IlluminateAuthAuthenticatable;
  101. use IlluminateDatabaseEloquentModel;
  102. use IlluminateAuthPasswordsCanResetPassword;
  103. use IlluminateContractsAuthAuthenticatable as AuthenticatableContract;
  104. use IlluminateContractsAuthCanResetPassword as CanResetPasswordContract;
  105.  
  106. class AdminLoginModel extends Model implements AuthenticatableContract, CanResetPasswordContract
  107. {
  108. use Authenticatable, CanResetPassword;
  109.  
  110. protected $table = 'admin_details';
  111. protected $fillable = ['username', 'password'];
  112. }
  113.  
  114. <?php
  115.  
  116. /*
  117. |--------------------------------------------------------------------------
  118. | Application Routes
  119. |--------------------------------------------------------------------------
  120. |
  121. | Here is where you can register all of the routes for an application.
  122. | It's a breeze. Simply tell Laravel the URIs it should respond to
  123. | and give it the controller to call when that URI is requested.
  124. |
  125. */
  126.  
  127. Route::get('/', function () {
  128. return view('welcome');
  129. });
  130.  
  131. Route::resource('dashboard','DashboardController');
  132. Route::resource('administrator','AdminLoginController');
  133. Route::resource('users','AdminLoginController');
  134. Route::resource('administrator/userAuthentication', 'AdminLoginController@userAuthentication');
  135.  
  136. <!DOCTYPE html>
  137. <html>
  138. <head>
  139. <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
  140. </head>
  141. <body>
  142. <div class="container">
  143. <h3>Login Form</h3>
  144.  
  145. {!! Form::open(array('url' => 'login', 'method' => 'post')) !!}
  146. <div class="form-group">
  147. {!! Form::label('UserName') !!}
  148. {!! Form::text('username', null,
  149. array(
  150. 'class'=>'form-control',
  151. 'placeholder'=>'Your UserName')) !!}
  152. </div>
  153. <div class="form-group">
  154. {!! Form::label('password') !!}
  155. {!! Form::text('password', null,
  156. array(
  157. 'class'=>'form-control',
  158. 'placeholder'=>'Your Password')) !!}
  159. </div>
  160.  
  161. <div class="form-group">
  162. {!! Form::submit('Login',
  163. array('class'=>'btn btn-primary')) !!}
  164. </div>
  165. {!! Form::close() !!}
  166.  
  167. </div>
  168. </body>
  169. </html>
  170.  
  171. <?php namespace App;
  172.  
  173. use IlluminateAuthAuthenticatable;
  174. use IlluminateDatabaseEloquentModel;
  175. use IlluminateAuthPasswordsCanResetPassword;
  176. use IlluminateContractsAuthAuthenticatable as AuthenticatableContract;
  177. use IlluminateContractsAuthCanResetPassword as CanResetPasswordContract;
  178.  
  179. class UserRegisters extends Model implements AuthenticatableContract, CanResetPasswordContract {
  180. use Authenticatable, CanResetPassword;
  181. protected $table = 'userregisters';
  182. protected $fillable = ['user_name', 'password'];
  183. }
  184. ?>
  185.  
  186. <?php namespace AppHttpControllers;
  187. use Input;
  188. use AppHttpRequests;
  189. use AppUser;
  190. use AppUserRegisters;
  191. use AppUserProfiles;
  192. use Validator;
  193. use View;
  194. use Auth;
  195. use AppHttpControllersRedirect;
  196. use Session;
  197. use Hash;
  198. use DB;
  199.  
  200. class UserRegisterController extends Controller
  201. {
  202. /**
  203. * Login a Registered Users.
  204. *
  205. */
  206. public function login(){
  207. $uname = Input::get('username');
  208. $password = Input::get('password');
  209. if (Auth::attempt(array('user_name' => $uname, 'password' => $password))){
  210. return "success";
  211. }
  212. else {
  213. return "Wrong Credentials";
  214. }
  215. }
  216. }
  217. }
  218.  
  219. Route::post('/login', 'UserRegisterController@login');
  220.  
  221. <?php
  222.  
  223. use IlluminateDatabaseSchemaBlueprint;
  224. use IlluminateDatabaseMigrationsMigration;
  225.  
  226. class Userregisters extends Migration
  227. {
  228. /**
  229. * Run the migrations.
  230. *
  231. * @return void
  232. */
  233. public function up()
  234. {
  235. Schema::create('userregisters', function($table)
  236. {
  237. $table->increments('id');
  238. $table->string('first_name', 128);
  239. $table->string('last_name', 128);
  240. $table->string('user_name', 128);
  241. $table->string('password', 128);
  242. $table->string('email', 128);
  243. $table->timestamps();
  244. });
  245. }
  246.  
  247. /**
  248. * Reverse the migrations.
  249. *
  250. * @return void
  251. */
  252. public function down()
  253. {
  254. Schema::drop('userregisters');
  255. }
  256. }
  257.  
  258. $email=$request->email;
  259. $password=$request->password;
  260.  
  261. if(Auth::attempt(['email'=>$email,'password'=>$password]))
  262. {
  263. return redirect()->intended('admin/dashboard');
  264. }
  265.  
  266. id|username|password|email|remember_token|created_at|updated_at
  267.  
  268. protected $table = 'users';
  269.  
  270. protected $fillable = ['username', 'email', 'password'];
  271.  
  272. public function loginPost(Request $request)
  273. {
  274. $email=$request->email;
  275. $password=$request->password;
  276. if(Auth::attempt(['email'=>$email,'password'=>$password]))
  277. {
  278. return redirect()->intended('admin/dashboard');
  279. }
  280.  
  281. return Redirect::to('login');
  282. }
  283.  
  284. $data=[];
  285. $data['email']=$request->email;
  286. $data['password']=Hash::make($password);
  287. User::create($data);
  288.  
  289. public function insert()
  290. {
  291. $data=[];
  292. $data['email']=$request->email;
  293. $data['password']=Hash::make($password);
  294. AdminLoginModel::create($data);
  295. }
Add Comment
Please, Sign In to add comment