samedi 22 octobre 2016

Is the following query is correct one?

I am using laravel eloquent model and i want to join multiple tables so i wrote following query but i didn't get the expected result. And the query is

\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}%")
    ->orWhere('communication_links.value', 'LIKE', "{$request->search_string}%")
    ->orWhere('contacts.fname', 'LIKE', "{$request->search_string}%")
    ->orWhere('contacts.lname', 'LIKE', "{$request->search_string}%")
    ->get();

Have I followed this correctly? What do you think?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire