newModelQuery(); foreach ($credentials as $key => $value) { if (Str::contains($key, 'password')) { continue; } if (is_array($value) || $value instanceof Arrayable) { $query->with([$this->email_model => function ($q) use ($key, $value) { $q->whereIn($key, $value); }]); } else { $query->with([$this->email_model => function ($q) use ($key, $value) { $q->where($key, $value); }]); } } return $query->first(); } }