mercredi 31 juillet 2019

Laravel How to join table and set a 'LIKE' query on Eloquent?

ENV:

Laravel 5.7.28

Database mysql

CentOS 7.2

I have 3 table like as below, I need join this 3 table and merge columns (customer.first_name,customer.last_name,customer.address,job.name,job.address,job.date) to set 'like' query.

For example, when $text = 'MS'; set 'like' '%'.$text.'%' can return blow (merge customer.first_name and customer.last_name)

customer.first_name = TOM

customer.last_name = SMITH

customer.address = Cecilia Chapman

job.name = ABC.Ltd

job.address = Iris Watson

job.date = 2019-01-10

  1. id table (relation belongs To table customer and job)
    • id
    • customer_id
    • job_id
  2. customer table
    • id
    • first_name
    • last_name
    • address
  3. job id
    • id
    • name
    • address
    • job_date


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire