diff --git a/app/AdminUser.php b/app/AdminUser.php index e1921d9..0e7858d 100644 --- a/app/AdminUser.php +++ b/app/AdminUser.php @@ -7,14 +7,15 @@ namespace ProVision\Administration; -use Validator; -use Illuminate\Support\Facades\Cache; -use Illuminate\Support\Facades\Config; -use Illuminate\Notifications\Notifiable; -use Zizaco\Entrust\Traits\EntrustUserTrait; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Foundation\Auth\User as Authenticatable; +use Illuminate\Notifications\Notifiable; +use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Facades\Config; +use Illuminate\Support\Facades\Hash; use ProVision\Administration\Notifications\ResetPassword; +use Validator; +use Zizaco\Entrust\Traits\EntrustUserTrait; class AdminUser extends Authenticatable { @@ -85,6 +86,15 @@ public function errors() return $this->errors; } + /** + * Password hash set + * @param string $value + */ + public function setPasswordAttribute($value) + { + $this->attributes['password'] = Hash::make($value); + } + /** * Send the password reset notification. * diff --git a/app/Console/Commands/CreateAdministrator.php b/app/Console/Commands/CreateAdministrator.php index eeb2106..b73b5ec 100644 --- a/app/Console/Commands/CreateAdministrator.php +++ b/app/Console/Commands/CreateAdministrator.php @@ -8,10 +8,10 @@ namespace ProVision\Administration\Console\Commands; use Illuminate\Console\Command; -use ProVision\Administration\Role; use Illuminate\Support\Facades\Hash; use ProVision\Administration\AdminUser; use ProVision\Administration\Http\Controllers\Systems\RolesRepairController; +use ProVision\Administration\Role; class CreateAdministrator extends Command { @@ -40,7 +40,7 @@ public function __construct() /* * command fix */ - $this->signature = config('provision_administration.command_prefix').':admin {email} {password}'; + $this->signature = config('provision_administration.command_prefix') . ':admin {email} {password}'; parent::__construct(); } @@ -65,22 +65,22 @@ public function handle() $adminUser = AdminUser::create([ 'name' => 'ProVision Administrator', 'email' => $this->argument('email'), - 'password' => Hash::make($this->argument('password')), + 'password' => $this->argument('password'), ]); $this->info('Creating admin user...'); - $this->info('email: '.$adminUser->email); - $this->info('password: '.$this->argument('password')); + $this->info('email: ' . $adminUser->email); + $this->info('password: ' . $this->argument('password')); } else { /* * Reset admin password */ - $adminUser->password = Hash::make($this->argument('password')); + $adminUser->password = $this->argument('password'); $adminUser->save(); $this->info('Reset admin user...'); - $this->info('email: '.$adminUser->email); - $this->info('password: '.$this->argument('password')); + $this->info('email: ' . $adminUser->email); + $this->info('password: ' . $this->argument('password')); } /* @@ -95,7 +95,7 @@ public function handle() $adminRole->save(); $this->info('Create admin role...'); } - if (! $adminUser->hasRole('admin')) { + if (!$adminUser->hasRole('admin')) { $this->info('Assign admin role...'); $adminUser->attachRole($adminRole); }