Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

199
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!