Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

202
Vistas
Why i get every Item from Database in Laravel

this is my code:

 $customer = CustomerRepository::getInstance()->read($id)->first();
 $contacts = $customer->getContacts();

 $data = $contacts->where('firstname', '=', 'test' )
->orWhere('lastname', '=', 'test2')
    ->orderBy('lastname', 'asc'])->paginate(15);

...

public function getContacts()
{
    return $this->morphToMany(Contact::class, 'contactable');
}

I only want the contacts from the customer which has the certain firstname or lastname , why i get every contact from the Database table?

UPDATE: So i found out, if i delete the orWhere clauses it works, but with the orWhere i get every contact. But how can i do it with the orWhere Clause?

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda