diff --git a/app/Console/Commands/CreateUserCommand.php b/app/Console/Commands/CreateUserCommand.php new file mode 100644 index 0000000..d051748 --- /dev/null +++ b/app/Console/Commands/CreateUserCommand.php @@ -0,0 +1,123 @@ + $value, + ], [ + 'email' => ['required', 'email:rfc', Rule::unique(User::class, 'email')] + ]); + + if ($validator->fails()) { + return $validator->messages()->first(); + } + } + ); + + $uuid = text( + label: 'What is your uuid?', + placeholder: 'E.g. U05ES1730UE', + required: 'Your uuid is required.', + validate: function (string $value) { + $validator = Validator::make([ + 'uuid' => $value, + ], [ + 'uuid' => ['required', Rule::unique(User::class, 'uuid')] + ]); + + if ($validator->fails()) { + return $validator->messages()->first(); + } + }, + hint: 'This is your slack User ID.' + ); + + $profilePic = text( + label: 'What is your profile pic?', + placeholder: 'E.g. https://secure.gravatar.com/avatar/f2ca68078ae3b3228b0307c20ae84dd2.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0015-512.png', + required: 'Your url is required.', + validate: function (string $value) { + $validator = Validator::make([ + 'url' => $value, + ], [ + 'url' => ['required', 'url'] + ]); + + if ($validator->fails()) { + return $validator->messages()->first(); + } + }, + hint: 'This is your slack profile url.' + ); + + $isAdmin = select( + label: 'Is your account an admin?', + options: [ + true => 'Yes', + false =>'No' + ], + ); + + $password = password( + label: 'What is your password?', + placeholder: '**********', + hint: 'One will be randomly generated if non is provided', + ); + + if (empty($password)) { + $password = Str::password(12); + $this->info("Randomly Generated Password: $password"); + } + + User::create([ + 'firstname' => $firstName, + 'lastname' => $lastName, + 'email' => $emailAddress, + 'uuid' => $uuid, + 'profile' => $profilePic, + 'status' => UserStatus::ACTIVE, + 'is_admin' => $isAdmin, + 'password' => $password, + ]); + + $this->info('Complete!'); + } +} diff --git a/app/Enums/UserStatus.php b/app/Enums/UserStatus.php new file mode 100644 index 0000000..7e6bc7f --- /dev/null +++ b/app/Enums/UserStatus.php @@ -0,0 +1,15 @@ + */ protected $fillable = [ - 'name', + 'firstname', + 'lastname', 'email', + 'uuid', + 'profile', + 'status', + 'is_admin', 'password', ]; @@ -38,7 +43,6 @@ class User extends Authenticatable * @var array */ protected $casts = [ - 'email_verified_at' => 'datetime', 'password' => 'hashed', ]; } diff --git a/app/Traits/EnumOptions.php b/app/Traits/EnumOptions.php new file mode 100644 index 0000000..1843141 --- /dev/null +++ b/app/Traits/EnumOptions.php @@ -0,0 +1,26 @@ +name; + if (Str::contains($label, '_')) { + $label = Str::replace('_', ' ', $label); + } + $options[] = [ + 'value' => $case->value, + 'label' => Str::title($label), + ]; + } + + return $options; + } +} diff --git a/app/Traits/EnumValues.php b/app/Traits/EnumValues.php new file mode 100644 index 0000000..a16a99f --- /dev/null +++ b/app/Traits/EnumValues.php @@ -0,0 +1,11 @@ +id(); - $table->string('name'); + $table->string('firstname'); + $table->string('lastname'); $table->string('email')->unique(); - $table->timestamp('email_verified_at')->nullable(); + $table->string('uuid')->unique(); + $table->string('profile'); + $table->string('status'); + $table->string('is_admin'); $table->string('password'); $table->rememberToken(); $table->timestamps(); diff --git a/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php b/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php deleted file mode 100644 index e828ad8..0000000 --- a/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php +++ /dev/null @@ -1,33 +0,0 @@ -id(); - $table->morphs('tokenable'); - $table->string('name'); - $table->string('token', 64)->unique(); - $table->text('abilities')->nullable(); - $table->timestamp('last_used_at')->nullable(); - $table->timestamp('expires_at')->nullable(); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('personal_access_tokens'); - } -}; diff --git a/resources/views/components/sidebar-nav.blade.php b/resources/views/components/sidebar-nav.blade.php index c59eab0..c87ad4e 100644 --- a/resources/views/components/sidebar-nav.blade.php +++ b/resources/views/components/sidebar-nav.blade.php @@ -2,7 +2,7 @@ {{ $slot }} diff --git a/resources/views/livewire/layout/navigation.blade.php b/resources/views/livewire/layout/navigation.blade.php index 38a3742..7e2dc38 100644 --- a/resources/views/livewire/layout/navigation.blade.php +++ b/resources/views/livewire/layout/navigation.blade.php @@ -44,9 +44,15 @@ new class extends Component aria-expanded="false" aria-haspopup="true"> {{-- TODO: Add User Image URL here --}} - +