Skip to content
This repository has been archived by the owner on Jul 24, 2023. It is now read-only.

Commit

Permalink
Set the model on the console command
Browse files Browse the repository at this point in the history
  • Loading branch information
stevebauman committed Apr 18, 2019
1 parent 2725530 commit a14d504
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/Commands/Console/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@

class Import extends Command
{
/**
* The user model to use for importing.
*
* @var string
*/
protected $model;

/**
* The signature of the console command.
*
Expand Down Expand Up @@ -92,13 +99,11 @@ public function import(array $users = []) : int

$this->output->progressStart(count($users));

$model = $this->model();

foreach ($users as $user) {
try {
// Import the user and retrieve it's model.
$model = Bus::dispatch(
new ImportUser($user, $model)
new ImportUser($user, $this->model())
);

// Set the users password.
Expand Down Expand Up @@ -305,15 +310,17 @@ protected function delete(User $user, Model $model)
}

/**
* Create a new instance of the eloquent model to use.
* Set and create a new instance of the eloquent model to use.
*
* @return Model
*/
protected function model() : Model
{
$model = $this->option('model') ?? Config::get('ldap_auth.model') ?: $this->determineModel();
if (! $this->model) {
$this->model = $this->option('model') ?? Config::get('ldap_auth.model') ?: $this->determineModel();
}

return new $model;
return new $this->model;
}

/**
Expand Down

0 comments on commit a14d504

Please sign in to comment.