Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.12 KB | None | 0 0
  1. @extends('app')
  2.  
  3. @section('content')
  4.  
  5. <h1>Регистрация</h1>
  6.  
  7. <form action="/user/" method="post">
  8. {{ csrf_field() }}
  9. <div class="form-group">
  10. <label for="email">Email</label>
  11. <input type="text" class="form-control" id="email" name="email">
  12. </div>
  13. <div class="form-group">
  14. <label for="login">Login</label>
  15. <input type="text" class="form-control" name="login">
  16. </div>
  17. <div class="form-group">
  18. <label for="password">Password</label>
  19. <input type="password" class="form-control" id="password" name="password">
  20. </div>
  21. <div class="form-group">
  22. <label for="password-repeat">Repeat password</label>
  23. <input type="password" class="form-control" id="password-repeat" name="password-repeat">
  24. </div>
  25. <button type="submit" class="btn btn-default">Регистрация</button>
  26. </form>
  27.  
  28. @stop
  29.  
  30. public function create()
  31. {
  32. $userConstuctor['login'] = Request::input('login');
  33. $userConstuctor['password'] = Request::input('password');
  34. $user = new User($userConstuctor);
  35. $user->setUser(Request::all());
  36. $user->save();
  37. }
  38.  
  39. <?php
  40.  
  41. namespace App;
  42.  
  43. use IlluminateDatabaseEloquentModel;
  44. use Session;
  45.  
  46. class User extends Model
  47. {
  48. const ADMIN = 1;
  49. const MANAGER = 2;
  50. const USER = 3;
  51.  
  52. public $login;
  53. public $password;
  54. private $email;
  55. private $firstName;
  56. private $secondName;
  57. private $lastName;
  58. private $avatar;
  59. private $userOptions = [];
  60. private $createdDate;
  61. private $rememberToken;
  62. private $active;
  63. private $groupId;
  64. public $timestamps = false;
  65. protected $fillable = ['login', 'password', 'email', 'created_date', 'remember_token', 'active', 'group_id'];
  66. protected $table = 'users';
  67.  
  68. public function __construct($userConstuctor)
  69. {
  70. $this->setLogin($userConstuctor['login']);
  71. $this->setPassword($userConstuctor['password']);
  72. }
  73.  
  74. public function setUser($user)
  75. {
  76. $this->setEmail($user['email']);
  77. $this->setCreatedDate();
  78. $this->setRememberToken($user['_token']);
  79. $this->setActive();
  80. $this->setGroupId();
  81. }
  82.  
  83. private function setLogin($login)
  84. {
  85. $this->login = $login;
  86. }
  87.  
  88. private function setPassword($password)
  89. {
  90. $this->password = md5($password);
  91. }
  92.  
  93. private function setEmail($email)
  94. {
  95. $this->email = $email;
  96. }
  97.  
  98. private function setCreatedDate()
  99. {
  100. $this->createdDate = date('Y-m-d H:i:s');
  101. }
  102.  
  103. private function setRememberToken($token)
  104. {
  105. $this->rememberToken = $token;
  106. }
  107.  
  108. private function setActive()
  109. {
  110. $this->active = false;
  111. }
  112.  
  113. private function setGroupId()
  114. {
  115. $this->groupId = self::USER;
  116. }
  117.  
  118. }
  119.  
  120. Schema::create('users', function (Blueprint $table) {
  121. $table->increments('id');
  122. $table->string('login')->unique();
  123. $table->string('email')->unique();
  124. $table->string('password');
  125. $table->string('first_name')->nullable();
  126. $table->string('second_name')->nullable();
  127. $table->string('last_name')->nullable();
  128. $table->string('avatar', 250)->nullable();
  129. $table->longText('user_options')->nullable();
  130. $table->timestamp('created_date');
  131. $table->boolean('active');
  132. $table->rememberToken('token');
  133. $table->integer('group_id');
  134. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement