Skip to content

Commit

Permalink
mutator
Browse files Browse the repository at this point in the history
  • Loading branch information
ibnudirsandev committed Nov 6, 2022
1 parent bd266ee commit 9b80950
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
15 changes: 10 additions & 5 deletions app/Console/Commands/SuperAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public function handle()
{
DB::beginTransaction();
try {
$google2fa = app('pragmarx.google2fa');
$NewSecretKey = $google2fa->generateSecretKey();
$result = User::select('id')->whereLevel(1)->first();
$username = !$this->option('username') ? 'ibnudirsan' : $this->option('username');
$email = !$this->option('email') ? 'admin@rumahdev.net' : $this->option('email');
Expand All @@ -55,12 +57,15 @@ public function handle()
'TeleID' => '0',
]);
$user->secret()->create([
'user_id' => $user->id
'user_id' => $user->id,
'secret2Fa' => $NewSecretKey
]);
$user->assignRole("SuperAdmin");
File::makeDirectory(public_path('assets/images/profile/'));
$this->components->info('Aready Created User '.$username);
$this->line('<bg=black;fg=white>..:: Created by RumahDev ::..</>');
$user->assignRole("SuperAdmin");
if(!File::exists(public_path('assets/images/profile/'))) {
File::makeDirectory(public_path('assets/images/profile/'));
}
$this->components->info('Aready Created User '.$username);
$this->line('<bg=black;fg=white>..:: Created by RumahDev ::..</>');
}
} catch (\Exception $e) {
DB::rollBack();
Expand Down
12 changes: 12 additions & 0 deletions app/Models/userSecret.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;

/*
Expand Down Expand Up @@ -44,4 +45,15 @@ class userSecret extends Model
protected $fillable = [
'user_id', 'isBlock', 'secret2Fa','statusOTP','timeOTP'
];


public function setsecret2faAttribute($value)
{
$this->attributes['secret2Fa'] = encrypt($value);
}

public function getsecret2faAttribute($value)
{
return decrypt($value);
}
}

0 comments on commit 9b80950

Please sign in to comment.