jeudi 22 mars 2018

Laravel : if record not found then search relational model

I am trying to find a record in User model , if the record doesn't exists in User model, Then find it in UserCompany model with relation name company in User model.

$companyUser = \App\User::whereHas('company', function ($query) use ($request) {
    $query->where('company_email', '=', $request->email);
})->where('email', $request->email)->get();

I am getting empty set there, What am i missing.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire