1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Arcanedev\LaravelAuth\Bases\Migration; |
4
|
|
|
use Arcanedev\LaravelAuth\Services\SocialAuthenticator; |
5
|
|
|
use Illuminate\Database\Schema\Blueprint; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class CreateUsersTable |
9
|
|
|
* |
10
|
|
|
* @author ARCANEDEV <[email protected]> |
11
|
|
|
* |
12
|
|
|
* @see \Arcanedev\LaravelAuth\Models\User |
13
|
|
|
*/ |
14
|
|
|
class CreateAuthUsersTable extends Migration |
15
|
|
|
{ |
16
|
|
|
/* ----------------------------------------------------------------- |
17
|
|
|
| Constructor |
18
|
|
|
| ----------------------------------------------------------------- |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Make a migration instance. |
23
|
|
|
*/ |
24
|
|
|
public function __construct() |
25
|
|
|
{ |
26
|
|
|
parent::__construct(); |
27
|
|
|
|
28
|
|
|
$this->setTable(config('laravel-auth.users.table', 'users')); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/* ----------------------------------------------------------------- |
32
|
|
|
| Main Methods |
33
|
|
|
| ----------------------------------------------------------------- |
34
|
|
|
*/ |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Run the migrations. |
38
|
|
|
*/ |
39
|
|
|
public function up() |
40
|
|
|
{ |
41
|
|
|
$this->createSchema(function (Blueprint $table) { |
42
|
|
|
$table->increments('id'); |
43
|
|
|
$table->string('username'); |
44
|
|
|
$table->string('first_name', 30)->nullable(); |
45
|
|
|
$table->string('last_name', 30)->nullable(); |
46
|
|
|
$table->string('email')->unique(); |
47
|
|
|
$table->timestamp('email_verified_at')->nullable(); |
48
|
|
|
$this->addCredentialsColumns($table); |
49
|
|
|
$table->rememberToken(); |
50
|
|
|
$table->boolean('is_admin')->default(0); |
51
|
|
|
$table->timestamp('last_activity')->nullable(); |
52
|
|
|
$table->timestamps(); |
53
|
|
|
$table->timestamp('activated_at')->nullable(); |
54
|
|
|
$table->softDeletes(); |
55
|
|
|
}); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/* ----------------------------------------------------------------- |
59
|
|
|
| Other Methods |
60
|
|
|
| ----------------------------------------------------------------- |
61
|
|
|
*/ |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Add credentials columns. |
65
|
|
|
* |
66
|
|
|
* @param \Illuminate\Database\Schema\Blueprint $table |
67
|
|
|
*/ |
68
|
|
|
private function addCredentialsColumns(Blueprint $table) |
69
|
|
|
{ |
70
|
|
|
if (SocialAuthenticator::isEnabled()) { |
71
|
|
|
$table->string('password')->nullable(); |
72
|
|
|
// Social network columns |
73
|
|
|
$table->string('social_provider')->nullable(); |
74
|
|
|
$table->string('social_provider_id')->unique()->nullable(); |
75
|
|
|
} |
76
|
|
|
else { |
77
|
|
|
$table->string('password'); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|