I am using folloing table structure
resource_type
id
type
communiction_links
id
inst_id
rety_id
cont_id
value
contact
id
fname
lname
image
park
I want search the pattern in in two tables and retrive data from two tables. if pattern is digit then i will search in communication_links and if pattern is alphabates then i will search in contact in fname or lname column (where communication_links's cont_id and contact's id should be same) and (communication_links's rety_id and resource_type's id should be same)
i wrote down following query but i got error.
$parent_contact = \App\Contact::join('communication_links','contacts.id','=','communication_links.cont_id')
->join('resource_types','resource_types.id','=','communication_links.rety_id')
->select('contacts.id','contacts.image','contacts.fname','contacts.lname','communication_links.value')
->where('resource_types.type','LIKE',"{mobile}%")
->where(function ($query) {
$query->where('communication_links.value','LIKE',"{$request->search_string}%")
->orWhere('contacts.fname','LIKE',"{$request->search_string}%")
->orWhere('contacts.lname','LIKE',"{$request->search_string}%");
})
->get();
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire