This repository was archived by the owner on Jul 24, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change 90
90
Found user ' John Doe' .
91
91
```
92
92
93
+ ## Import Scope
94
+
95
+ > ** Note** : This feature was added in v6.0.2.
96
+
97
+ To customize the query that locates the LDAP users local database model, you may
98
+ use the ` useScope ` method on the ` Import ` command in your ` AppServiceProvider ` :
99
+
100
+ ``` php
101
+ use App\Scopes\LdapUserImportScope;
102
+ use Adldap\Laravel\Commands\Import;
103
+
104
+ public function boot()
105
+ {
106
+ Import::useScope(LdapUserImportScope::class);
107
+ }
108
+ ```
109
+
110
+ The custom scope:
111
+
112
+ > ** Note** : It's recommended that your custom scope extend the default ` UserImportScope ` .
113
+ > Otherwise, it must implement the ` Illuminate\Database\Eloquent\Scope ` interface.
114
+
115
+ ``` php
116
+ namespace App\Scopes;
117
+
118
+ use Illuminate\Support\Str;
119
+ use Adldap\Laravel\Commands\UserImportScope as BaseScope;
120
+
121
+ class LdapUserImportScope extends BaseScope
122
+ {
123
+ /**
124
+ * Apply the scope to a given Eloquent query builder.
125
+ *
126
+ * @param Builder $query
127
+ * @param Model $model
128
+ *
129
+ * @return void
130
+ */
131
+ public function apply(Builder $query, Model $model)
132
+ {
133
+ $query
134
+ ->where(Resolver::getDatabaseIdColumn(), '=', $this->getGuid())
135
+ ->orWhere(Resolver::getDatabaseUsernameColumn(), '=', $this->getUsername());
136
+ }
137
+ }
138
+ ```
139
+
93
140
## Command Options
94
141
95
142
### Filter
You can’t perform that action at this time.
0 commit comments