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

Commit 1edf798

Browse files
committed
Added model command option
1 parent 4421640 commit 1edf798

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Commands/Console/Import.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Adldap\Laravel\Commands\Import as ImportUser;
1313
use Illuminate\Console\Command;
1414
use Illuminate\Support\Facades\Bus;
15+
use Illuminate\Support\Facades\Event;
1516
use Illuminate\Support\Facades\Config;
1617
use Illuminate\Database\Eloquent\Model;
1718

@@ -24,6 +25,7 @@ class Import extends Command
2425
*/
2526
protected $signature = 'adldap:import {user? : The specific user to import.}
2627
{--f|filter= : The raw LDAP filter for limiting users imported.}
28+
{--m|model= : The model to use for importing users.}
2729
{--d|delete : Soft-delete the users model if their LDAP account is disabled.}
2830
{--r|restore : Restores soft-deleted models if their LDAP account is enabled.}
2931
{--no-log : Disables logging successful and unsuccessful imports.}';
@@ -233,7 +235,7 @@ protected function save(User $user, Model $model) : bool
233235
if ($model->save() && $model->wasRecentlyCreated) {
234236
$imported = true;
235237

236-
event(new Imported($user, $model));
238+
Event::dispatch(new Imported($user, $model));
237239

238240
// Log the successful import.
239241
if ($this->isLogging()) {
@@ -303,13 +305,13 @@ protected function delete(User $user, Model $model)
303305
}
304306

305307
/**
306-
* Create a new instance of the configured authentication model.
308+
* Create a new instance of the eloquent model to use.
307309
*
308310
* @return Model
309311
*/
310312
protected function model() : Model
311313
{
312-
$model = Config::get('ldap_auth.model') ?? $this->determineModel();
314+
$model = $this->option('model') ?? Config::get('ldap_auth.model', $this->determineModel());
313315

314316
return new $model;
315317
}

0 commit comments

Comments
 (0)