diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index ccab21f..5bf46cb 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -215,7 +215,6 @@ ->in([ __DIR__.'/config', __DIR__.'/database', - __DIR__.'/lang', __DIR__.'/src', __DIR__.'/tests/Feature', __DIR__.'/tests/Unit', diff --git a/database/migrations-playground/2014_10_12_000000_create_users_table.php b/database/migrations-playground/2014_10_12_000000_create_users_table.php index d23981e..b68c554 100644 --- a/database/migrations-playground/2014_10_12_000000_create_users_table.php +++ b/database/migrations-playground/2014_10_12_000000_create_users_table.php @@ -14,59 +14,78 @@ public function up(): void { Schema::create('users', function (Blueprint $table) { - // IDs + // Primary key + $table->uuid('id')->primary(); - $table->uuid('created_id')->nullable()->index(); - $table->uuid('modified_id')->nullable()->index(); + // IDs + + $table->uuid('created_by_id')->nullable()->index(); + $table->uuid('modified_by_id')->nullable()->index(); + $table->string('user_type')->nullable()->index(); // Date columns $table->timestamps(); + $table->timestamp('email_verified_at')->nullable(); + // $table->dateTime('email_verified_at')->nullable(); - // Status + $table->dateTime('banned_at')->nullable(); + $table->dateTime('suspended_at')->nullable(); $table->softDeletes(); - $table->tinyInteger('active')->unsigned()->index()->default(0); - $table->tinyInteger('banned')->unsigned()->index()->default(0); - $table->tinyInteger('closed')->unsigned()->index()->default(0); - $table->tinyInteger('flagged')->unsigned()->index()->default(0); - $table->tinyInteger('internal')->unsigned()->index()->default(0); - $table->tinyInteger('locked')->unsigned()->index()->default(0); + // Permissions - // UI + $table->bigInteger('gids')->default(0)->unsigned(); + $table->bigInteger('po')->default(0)->unsigned(); + $table->bigInteger('pg')->default(0)->unsigned(); + $table->bigInteger('pw')->default(0)->unsigned(); + + $table->rememberToken(); - $table->string('style', 128)->default(''); - $table->string('klass', 128)->default(''); - $table->string('icon', 128)->default(''); + $table->string('role')->default(''); + + // Status - // Entity columns + $table->bigInteger('status')->default(0)->unsigned(); + $table->bigInteger('rank')->default(0); + $table->bigInteger('size')->default(0); + + // Flags + + $table->boolean('active')->default(1)->index(); + $table->boolean('banned')->default(0)->index(); + $table->boolean('flagged')->default(0)->index(); + $table->boolean('internal')->default(0)->index(); + $table->boolean('locked')->default(0)->index(); + $table->boolean('problem')->default(0)->index(); + $table->boolean('suspended')->default(0)->index(); + $table->boolean('unknown')->default(0)->index(); + + // Strings $table->string('name')->default(''); $table->string('email')->unique(); $table->string('password')->default(''); - $table->string('phone')->default(''); + $table->string('phone')->nullable(); $table->string('locale')->default(''); $table->string('timezone')->default(''); - $table->rememberToken(); - - $table->string('role')->default(''); + $table->string('label')->default(''); + $table->string('title')->default(''); + $table->string('byline')->default(''); + $table->string('slug')->nullable()->default(null)->index(); // A link to the external source of the user. - $table->string('url', 512)->default(''); + $table->string('url')->default(''); - // Description is an internal field. - $table->string('description', 512)->default(''); - - $table->string('image', 512)->default(''); - $table->string('avatar', 512)->default(''); + $table->string('description')->default(''); // The introduction should be the first 255 characters or less of the content. // The introduction is visible to the client. No HTML. - $table->string('introduction', 512)->default(''); + $table->string('introduction')->default(''); // The HTML content of the user. $table->mediumText('content')->nullable(); @@ -74,30 +93,30 @@ public function up(): void // The summary of the content, HTML allowed, to be shown to the client. $table->mediumText('summary')->nullable(); + // UI + + $table->string('icon')->default(''); + $table->string('image')->default(''); + $table->string('avatar')->default(''); + $table->json('ui')->nullable()->default(new Expression('(JSON_OBJECT())')); + $table->json('abilities') ->default(new Expression('(JSON_ARRAY())')) ->comment('Array of ability strings'); - $table->json('accounts') - ->default(new Expression('(JSON_OBJECT())')) - ->comment('User accounts object'); - $table->json('address') - ->default(new Expression('(JSON_OBJECT())')) - ->comment('User address object'); - $table->json('contact') - ->default(new Expression('(JSON_OBJECT())')) - ->comment('User contact object'); - $table->json('meta') - ->default(new Expression('(JSON_OBJECT())')) - ->comment('Model meta object'); - $table->json('notes') - ->default(new Expression('(JSON_ARRAY())')) - ->comment('Array of note objects'); - $table->json('options') - ->default(new Expression('(JSON_OBJECT())')) - ->comment('Model options object'); - $table->json('registration') - ->default(new Expression('(JSON_OBJECT())')) - ->comment('Registration information object'); + $table->longText('accounts') + ->comment('Encrypted user account objects'); + $table->longText('address') + ->comment('Encrypted user address object'); + $table->longText('contact') + ->comment('Encrypted contact object'); + $table->longText('meta') + ->comment('Encrypted meta object'); + $table->longText('notes') + ->comment('Encrypted array of note objects'); + $table->longText('options') + ->comment('Encrypted options object'); + $table->longText('registration') + ->comment('Encrypted registration information object'); $table->json('roles') ->default(new Expression('(JSON_ARRAY())')) ->comment('Array of role strings'); @@ -107,6 +126,8 @@ public function up(): void $table->json('privileges') ->default(new Expression('(JSON_ARRAY())')) ->comment('Array of privilege strings'); + $table->longText('sources') + ->comment('Encrypted array of sources'); }); } diff --git a/src/Models/User.php b/src/Models/User.php index e71beda..e7117c4 100644 --- a/src/Models/User.php +++ b/src/Models/User.php @@ -7,6 +7,7 @@ use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Database\Eloquent\Concerns\HasUuids; use Illuminate\Database\Eloquent\Factories\HasFactory; +use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; @@ -17,6 +18,7 @@ class User extends Authenticatable implements Contracts\Abilities, Contracts\Adm { use HasFactory, Notifiable; use HasUuids; + use SoftDeletes; use Traits\Abilities; use Traits\Admin; use Traits\Privileges; @@ -28,26 +30,88 @@ class User extends Authenticatable implements Contracts\Abilities, Contracts\Adm * @var array */ protected $attributes = [ + 'created_by_id' => null, + 'modified_by_id' => null, + 'user_type' => null, + 'created_at' => null, + 'updated_at' => null, + 'deleted_at' => null, + 'banned_at' => null, + 'suspended_at' => null, + 'gids' => 0, + 'po' => 0, + 'pg' => 0, + 'pw' => 0, + 'status' => 0, + 'rank' => 0, + 'size' => 0, + 'active' => true, + 'banned' => false, + 'flagged' => false, + 'internal' => false, + 'locked' => false, + 'problem' => false, + 'suspended' => false, + 'unknown' => false, + 'name' => '', + 'email' => '', + 'password' => '', + 'phone' => null, + 'locale' => '', + 'timezone' => '', + 'label' => '', + 'title' => '', + 'byline' => '', + 'slug' => null, + 'url' => '', + 'description' => '', + 'introduction' => '', + 'content' => null, + 'summary' => null, + 'icon' => '', + 'image' => '', + 'avatar' => '', // JSON + 'ui' => '{}', // Abilities are shared with SPAs - 'abilities' => '{}', + 'abilities' => '[]', 'accounts' => '{}', 'address' => '{}', + 'contact' => '{}', 'meta' => '{}', 'notes' => '[]', 'options' => '{}', - 'registration' => '[]', + 'registration' => '{}', 'roles' => '[]', 'permissions' => '[]', 'privileges' => '[]', + 'sources' => '[]', ]; /** * The attributes that are mass assignable. * - * @var string[] + * @var array */ protected $fillable = [ + 'user_type', + 'resolved_at', + 'suspended_at', + 'gids', + 'po', + 'pg', + 'pw', + 'status', + 'rank', + 'size', + 'active', + 'banned', + 'flagged', + 'internal', + 'locked', + 'problem', + 'suspended', + 'unknown', 'name', 'email', 'address', @@ -55,12 +119,23 @@ class User extends Authenticatable implements Contracts\Abilities, Contracts\Adm 'phone', 'locale', 'timezone', + 'label', + 'title', + 'byline', + 'slug', + 'url', 'description', - 'style', - 'klass', + 'introduction', + 'content', + 'summary', 'icon', 'image', 'avatar', + 'ui', + 'assets', + 'meta', + 'options', + 'sources', ]; /** @@ -69,8 +144,16 @@ class User extends Authenticatable implements Contracts\Abilities, Contracts\Adm * @var array */ protected $hidden = [ + 'banned_at', + 'suspended_at', 'password', 'remember_token', + 'banned', + 'flagged', + 'internal', + 'problem', + 'suspended', + 'unknown', 'accounts', 'address', 'contact', @@ -81,6 +164,7 @@ class User extends Authenticatable implements Contracts\Abilities, Contracts\Adm 'roles', 'permissions', 'privileges', + 'sources', ]; /** @@ -89,39 +173,51 @@ class User extends Authenticatable implements Contracts\Abilities, Contracts\Adm * @var array */ protected $casts = [ - // 'email_verified_at' => 'datetime', + 'created_at' => 'datetime', + 'updated_at' => 'datetime', + 'deleted_at' => 'datetime', + 'email_verified_at' => 'datetime', + 'banned_at' => 'datetime', + 'suspended_at' => 'datetime', + 'gids' => 'integer', + 'po' => 'integer', + 'pg' => 'integer', + 'pw' => 'integer', + 'status' => 'integer', + 'rank' => 'integer', + 'size' => 'integer', + // Boolean + 'active' => 'boolean', + 'banned' => 'boolean', + 'flagged' => 'boolean', + 'internal' => 'boolean', + 'locked' => 'boolean', + 'problem' => 'boolean', + 'suspended' => 'boolean', + 'unknown' => 'boolean', // 'id' => 'uuid', 'name' => 'string', 'email' => 'string', 'locale' => 'string', - 'phone' => 'string', + 'phone' => 'encrypted', 'timezone' => 'string', 'role' => 'string', 'description' => 'string', 'image' => 'string', 'avatar' => 'string', - // Boolean - 'active' => 'boolean', - 'banned' => 'boolean', - 'closed' => 'boolean', - 'flagged' => 'boolean', - 'internal' => 'boolean', - 'locked' => 'boolean', - // dates - 'email_verified_at' => 'datetime', - // 'deleted_at' => 'datetime', // json 'abilities' => 'array', - 'accounts' => 'array', - 'address' => 'array', - 'contact' => 'array', - 'meta' => 'array', - 'notes' => 'array', - 'options' => 'array', - 'registration' => 'array', + 'accounts' => 'encrypted:array', + 'address' => 'encrypted:array', + 'contact' => 'encrypted:array', + 'meta' => 'encrypted:array', + 'notes' => 'encrypted:array', + 'options' => 'encrypted:array', + 'registration' => 'encrypted:array', 'roles' => 'array', 'permissions' => 'array', 'privileges' => 'array', + 'ui' => 'array', ]; /** diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 731ea07..0f19db7 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -24,10 +24,6 @@ public function boot(): void $config = config($this->package); if (! empty($config['load']) && is_array($config['load'])) { - // $this->loadTranslationsFrom( - // dirname(__DIR__).'/lang', - // 'playground' - // ); if ($this->app->runningInConsole()) { // Publish configuration