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

Commit 442815b

Browse files
committed
Use array support class instead of helpers due to depreciation
1 parent e7e60f0 commit 442815b

File tree

4 files changed

+20
-18
lines changed

4 files changed

+20
-18
lines changed

src/AdldapAuthServiceProvider.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use RuntimeException;
66
use Adldap\AdldapInterface;
77
use Illuminate\Auth\Events\Login;
8+
use Illuminate\Support\Arr;
89
use Illuminate\Support\Facades\Auth;
910
use Illuminate\Support\Facades\Event;
1011
use Illuminate\Support\Facades\Config;
@@ -90,7 +91,7 @@ protected function makeUserProvider(Hasher $hasher, array $config)
9091
if (is_a($provider, DatabaseUserProvider::class, $allowString = true)) {
9192
// We will try to retrieve their model from the config file,
9293
// otherwise we will try to use the providers config array.
93-
$model = Config::get('ldap_auth.model') ?? array_get($config, 'model');
94+
$model = Config::get('ldap_auth.model') ?? Arr::get($config, 'model');
9495

9596
if (! $model) {
9697
throw new RuntimeException(

src/Commands/Console/Import.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use RuntimeException;
77
use Adldap\Models\User;
88
use UnexpectedValueException;
9+
use Illuminate\Support\Arr;
910
use Illuminate\Console\Command;
1011
use Adldap\Laravel\Events\Imported;
1112
use Illuminate\Support\Facades\Bus;
@@ -334,7 +335,7 @@ protected function determineModel()
334335
{
335336
// Retrieve all of the configured authentication providers that
336337
// use the LDAP driver and have a configured model.
337-
$providers = array_where(Config::get('auth.providers'), function ($value, $key) {
338+
$providers = Arr::where(Config::get('auth.providers'), function ($value, $key) {
338339
return $value['driver'] == 'ldap' && array_key_exists('model', $value);
339340
});
340341

src/Commands/SyncPassword.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Adldap\Laravel\Commands;
44

55
use Illuminate\Support\Str;
6+
use Illuminate\Support\Arr;
67
use Illuminate\Support\Facades\Hash;
78
use Illuminate\Support\Facades\Config;
89
use Illuminate\Database\Eloquent\Model;
@@ -109,7 +110,7 @@ protected function hasPasswordColumn() : bool
109110
*/
110111
protected function password()
111112
{
112-
return array_get($this->credentials, 'password');
113+
return Arr::get($this->credentials, 'password');
113114
}
114115

115116
/**

src/Resolvers/UserResolver.php

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Adldap\Models\User;
77
use Adldap\Query\Builder;
88
use Adldap\AdldapInterface;
9+
use Illuminate\Support\Arr;
910
use Illuminate\Support\Facades\Auth;
1011
use Illuminate\Support\Facades\Event;
1112
use Illuminate\Support\Facades\Config;
@@ -140,20 +141,8 @@ public function query() : Builder
140141

141142
$query->select($selects);
142143

143-
$scopes = Config::get('ldap_auth.scopes', []);
144-
145-
if (is_array($scopes)) {
146-
foreach ($scopes as $scope) {
147-
// Here we will use Laravel's IoC container to construct our scope.
148-
// This allows us to utilize any Laravel dependencies in
149-
// the scopes constructor that may be needed.
150-
151-
/** @var \Adldap\Laravel\Scopes\ScopeInterface $scope */
152-
$scope = app($scope);
153-
154-
// With the scope constructed, we can apply it to our query.
155-
$scope->apply($query);
156-
}
144+
foreach ($this->getQueryScopes() as $scope) {
145+
app($scope)->apply($query);
157146
}
158147

159148
return $query;
@@ -200,7 +189,7 @@ public function getDatabaseIdColumn() : string
200189
*/
201190
protected function getPasswordFromCredentials($credentials)
202191
{
203-
return array_get($credentials, 'password');
192+
return Arr::get($credentials, 'password');
204193
}
205194

206195
/**
@@ -234,4 +223,14 @@ protected function getLdapAuthConnectionName()
234223
{
235224
return Config::get('ldap_auth.connection', 'default');
236225
}
226+
227+
/**
228+
* Returns the configured query scopes.
229+
*
230+
* @return array
231+
*/
232+
protected function getQueryScopes()
233+
{
234+
return Config::get('ldap_auth.scopes', []);
235+
}
237236
}

0 commit comments

Comments
 (0)