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