Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @extends('app')
- @section('content')
- <h1>Регистрация</h1>
- <form action="/user/" method="post">
- {{ csrf_field() }}
- <div class="form-group">
- <label for="email">Email</label>
- <input type="text" class="form-control" id="email" name="email">
- </div>
- <div class="form-group">
- <label for="login">Login</label>
- <input type="text" class="form-control" name="login">
- </div>
- <div class="form-group">
- <label for="password">Password</label>
- <input type="password" class="form-control" id="password" name="password">
- </div>
- <div class="form-group">
- <label for="password-repeat">Repeat password</label>
- <input type="password" class="form-control" id="password-repeat" name="password-repeat">
- </div>
- <button type="submit" class="btn btn-default">Регистрация</button>
- </form>
- @stop
- public function create()
- {
- $userConstuctor['login'] = Request::input('login');
- $userConstuctor['password'] = Request::input('password');
- $user = new User($userConstuctor);
- $user->setUser(Request::all());
- $user->save();
- }
- <?php
- namespace App;
- use IlluminateDatabaseEloquentModel;
- use Session;
- class User extends Model
- {
- const ADMIN = 1;
- const MANAGER = 2;
- const USER = 3;
- public $login;
- public $password;
- private $email;
- private $firstName;
- private $secondName;
- private $lastName;
- private $avatar;
- private $userOptions = [];
- private $createdDate;
- private $rememberToken;
- private $active;
- private $groupId;
- public $timestamps = false;
- protected $fillable = ['login', 'password', 'email', 'created_date', 'remember_token', 'active', 'group_id'];
- protected $table = 'users';
- public function __construct($userConstuctor)
- {
- $this->setLogin($userConstuctor['login']);
- $this->setPassword($userConstuctor['password']);
- }
- public function setUser($user)
- {
- $this->setEmail($user['email']);
- $this->setCreatedDate();
- $this->setRememberToken($user['_token']);
- $this->setActive();
- $this->setGroupId();
- }
- private function setLogin($login)
- {
- $this->login = $login;
- }
- private function setPassword($password)
- {
- $this->password = md5($password);
- }
- private function setEmail($email)
- {
- $this->email = $email;
- }
- private function setCreatedDate()
- {
- $this->createdDate = date('Y-m-d H:i:s');
- }
- private function setRememberToken($token)
- {
- $this->rememberToken = $token;
- }
- private function setActive()
- {
- $this->active = false;
- }
- private function setGroupId()
- {
- $this->groupId = self::USER;
- }
- }
- Schema::create('users', function (Blueprint $table) {
- $table->increments('id');
- $table->string('login')->unique();
- $table->string('email')->unique();
- $table->string('password');
- $table->string('first_name')->nullable();
- $table->string('second_name')->nullable();
- $table->string('last_name')->nullable();
- $table->string('avatar', 250)->nullable();
- $table->longText('user_options')->nullable();
- $table->timestamp('created_date');
- $table->boolean('active');
- $table->rememberToken('token');
- $table->integer('group_id');
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement