Total Complexity | 4 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
9 | class User extends Model |
||
10 | { |
||
11 | protected $table = 'users'; |
||
12 | protected $fillable = ['name', 'email', 'password', 'token', 'is_admin']; |
||
13 | protected $hidden = ['password', 'token']; |
||
14 | |||
15 | public static function createTable(): void |
||
16 | { |
||
17 | DB::schema()->create((new static())->table, function (Blueprint $table) { |
||
18 | $table->increments('id'); |
||
19 | $table->string('name'); |
||
20 | $table->string('email')->unique(); |
||
21 | $table->string('password'); |
||
22 | $table->string('token')->nullable(); |
||
23 | $table->boolean('is_admin')->default(false); |
||
24 | $table->timestamps(); |
||
25 | }); |
||
26 | } |
||
27 | |||
28 | public static function createAdmin(): bool |
||
29 | { |
||
30 | return (null !== User::create([ |
||
31 | 'name' => 'admin', |
||
32 | 'email' => '[email protected]', |
||
33 | 'password' => password_hash('password', PASSWORD_ARGON2ID), |
||
34 | 'token' => null, |
||
35 | 'is_admin' => true, |
||
36 | ]) |
||
37 | ); |
||
38 | } |
||
39 | |||
40 | public function saveToken($token) |
||
44 | } |
||
45 | |||
46 | public function getToken() |
||
49 | } |
||
50 | } |
||
51 |