Skip to content

Commit 03f39fc

Browse files
committed
Update user model and migrations to match Laravel 6.0 defaults
1 parent db1c6e5 commit 03f39fc

6 files changed

+15
-22
lines changed
Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,20 @@
1-
<?php namespace Kodeine\Acl\Models\Eloquent;
2-
3-
use Illuminate\Database\Eloquent\Model;
4-
use Illuminate\Auth\Authenticatable;
1+
<?php
2+
namespace Kodeine\Acl\Models\Eloquent;
53

4+
use Illuminate\Contracts\Auth\MustVerifyEmail;
65
use Illuminate\Database\Eloquent\SoftDeletes;
7-
8-
use Illuminate\Auth\Passwords\CanResetPassword;
6+
use Illuminate\Foundation\Auth\User as Authenticatable;
7+
use Illuminate\Notifications\Notifiable;
98
use Kodeine\Acl\Traits\HasRole;
109

11-
class User extends Model
10+
class User extends Authenticatable
1211
{
13-
use Authenticatable, CanResetPassword, HasRole, SoftDeletes;
12+
use HasRole, SoftDeletes;
1413

1514
/**
1615
* The attributes that are fillable via mass assignment.
1716
*
1817
* @var array
1918
*/
20-
protected $fillable = ['username', 'first_name', 'last_name', 'email', 'password',];
21-
22-
/**
23-
* The database table used by the model.
24-
*
25-
* @var string
26-
*/
27-
protected $table = 'users';
19+
protected $fillable = ['name', 'email', 'password',];
2820
}

src/migrations/2015_02_07_172633_create_role_user_table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function up()
2626
$table->increments('id');
2727

2828
$table->integer('role_id')->unsigned()->index()->foreign()->references("id")->on("roles")->onDelete("cascade");
29-
$table->integer('user_id')->unsigned()->index()->foreign()->references("id")->on("users")->onDelete("cascade");
29+
$table->bigInteger('user_id')->unsigned()->index()->foreign()->references("id")->on("users")->onDelete("cascade");
3030

3131
$table->timestamps();
3232

src/migrations/2015_02_17_152439_create_permission_user_table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function up()
2525
Schema::create($this->prefix . 'permission_user', function (Blueprint $table) {
2626
$table->increments('id');
2727
$table->integer('permission_id')->unsigned()->index()->references('id')->on('permissions')->onDelete('cascade');
28-
$table->integer('user_id')->unsigned()->index()->references('id')->on('users')->onDelete('cascade');
28+
$table->bigInteger('user_id')->unsigned()->index()->references('id')->on('users')->onDelete('cascade');
2929
$table->timestamps();
3030
});
3131
}

src/migrations/2016_02_06_172606_create_users_table.php renamed to src/migrations/2016_02_06_172606_create_users_table_if_doesnt_exist.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use Illuminate\Database\Schema\Blueprint;
44
use Illuminate\Database\Migrations\Migration;
55

6-
class CreateUsersTable extends Migration
6+
class CreateUsersTableIfDoesntExist extends Migration
77
{
88

99
/**

tests/Models/UserTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function itCanAttachRole()
6060
]);
6161

6262
$user = new User();
63-
$user->username = 'Role test';
63+
$user->name = 'Role test';
6464
$user->email = '[email protected]';
6565
$user->password = 'RoleTest';
6666
$user->save();
@@ -97,7 +97,7 @@ public function itCanAttachRoleAndPermission()
9797
$role->syncPermissions($permission);
9898

9999
$user = new User();
100-
$user->username = 'Role test';
100+
$user->name = 'Role test';
101101
$user->email = '[email protected]';
102102
$user->password = 'RoleTest';
103103
$user->save();
@@ -134,7 +134,7 @@ public function cacheTest()
134134
$role->syncPermissions($permission);
135135

136136
$user = new User();
137-
$user->username = 'Cache test';
137+
$user->name = 'Cache test';
138138
$user->email = '[email protected]';
139139
$user->password = 'CacheTest';
140140
$user->save();

tests/TestCase.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ protected function getMigrationsDestPath()
119119
*/
120120
protected function migrate()
121121
{
122+
$this->loadLaravelMigrations();
122123
$this->loadMigrationsFrom($this->getMigrationsSrcPath());
123124
}
124125

0 commit comments

Comments
 (0)