2017_09_01_000000_create_users_table.php
1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email');
$table->string('password');
$table->rememberToken();
$table->string('picture')->nullable();
$table->timestamp('last_logged_in_at')->nullable();
$table->boolean('enabled')->default(1);
$table->timestamps();
$table->softDeletes();
$table->unique(['email', 'deleted_at']);
});
// Create table for associating companies to users (Many To Many Polymorphic)
Schema::create('user_companies', function (Blueprint $table) {
$table->integer('user_id')->unsigned();
$table->integer('company_id')->unsigned();
$table->string('user_type');
$table->primary(['user_id', 'company_id', 'user_type']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
// Cascade table first
Schema::dropIfExists('user_companies');
Schema::dropIfExists('users');
}
}