createModel()->newQuery(); foreach ($credentials as $key => $value) { if (! Str::contains($key, 'password')) { $query->where($key, $value); } } // @phpstan-ignore-next-line return $query->withTrashed()->first(); } /** * Validate a customer against the given credentials. * * @throws \ErrorException If model provided is not a Customer or connection to server fails. */ public function validateCredentials(Authenticatable $customer, array $credentials): bool { /** @var \App\Models\Customer $customer */ if ($customer instanceof Customer) { throw new \ErrorException('Cannot authenticate any thing else than ' . Customer::class); } // @phpstan-ignore-next-line $plain = $credentials['password']; /** @var \App\Models\Customer $customer */ if ($this->hasher->check($plain, $customer->getAuthPassword())) { // * Restore customer return boolval($customer->restore()); } return false; } }