Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Mar 3, 2019
1 parent accb93b commit 9bb7685
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions src/Illuminate/Auth/EloquentUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public function retrieveById($identifier)
{
$model = $this->createModel();

return $this->modelQuery($model)
->where($model->getAuthIdentifierName(), $identifier)
->first();
return $this->newModelQuery($model)
->where($model->getAuthIdentifierName(), $identifier)
->first();
}

/**
Expand All @@ -63,15 +63,18 @@ public function retrieveByToken($identifier, $token)
{
$model = $this->createModel();

$retrievedModel = $this->modelQuery($model)->where($model->getAuthIdentifierName(), $identifier)->first();
$retrievedModel = $this->newModelQuery($model)->where(
$model->getAuthIdentifierName(), $identifier
)->first();

if (! $retrievedModel) {
return null;
}

$rememberToken = $retrievedModel->getRememberToken();

return $rememberToken && hash_equals($rememberToken, $token) ? $retrievedModel : null;
return $rememberToken && hash_equals($rememberToken, $token)
? $retrievedModel : null;
}

/**
Expand Down Expand Up @@ -111,7 +114,7 @@ public function retrieveByCredentials(array $credentials)
// First we will add each credential element to the query as a where clause.
// Then we can execute the query and, if we found a user, return it in a
// Eloquent User "model" that will be utilized by the Guard instances.
$query = $this->modelQuery();
$query = $this->newModelQuery();

foreach ($credentials as $key => $value) {
if (Str::contains($key, 'password')) {
Expand Down Expand Up @@ -143,30 +146,28 @@ public function validateCredentials(UserContract $user, array $credentials)
}

/**
* Create a new instance of the model.
* Get a new query builder for the model instance.
*
* @return \Illuminate\Database\Eloquent\Model
* @param \Illuminate\Database\Eloquent\Model|null $model
* @return \Illuminate\Database\Eloquent\Builder
*/
public function createModel()
protected function newModelQuery($model = null)
{
$class = '\\'.ltrim($this->model, '\\');

return new $class;
return is_null($model)
? $this->createModel()->newQuery()
: $model->newQuery();
}

/**
* Get a new query builder for the model instance.
* Create a new instance of the model.
*
* @param \Illuminate\Database\Eloquent\Model|null $model
* @return \Illuminate\Database\Eloquent\Builder
* @return \Illuminate\Database\Eloquent\Model
*/
protected function modelQuery($model = null)
public function createModel()
{
if (is_null($model)) {
$model = $this->createModel();
}
$class = '\\'.ltrim($this->model, '\\');

return $model->newQuery();
return new $class;
}

/**
Expand Down

0 comments on commit 9bb7685

Please sign in to comment.