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