php - laravel eloquent eager loading nested condition -


I have two tables using curious loading and then using the nested position in that curious loading :

  // Migration (schema :: Create ('Leeds', Function (BluePrint $ table) {$ table-> Engine = 'InDebby') for lead table public function up; $ Table- & gt; id '); $ table-> string (' first_name ', 255); $ table-> string (' surname ', 255);}); Schema :: table ('Leeds', function ($ table) {$ table-> foreign ('create_by') - & gt; context ('id') -> ('employee') -> gt; ; OnDelete ('waterfall');}); } // Lead expansion email lead to public function () {schema :: create ('lead_detail_emails', function (blueprint $ table) {$ table-> engine = 'innoDB'; $ table- & gt; increment ('Id'); $ table-> integer ('lead_id') - & gt; unsigned (); $ table-> string ('email', 255);}); Schema :: table ('Lead_ details_males', function ($ table) {$ table-> foreign ('lead_id') -> context ('id') -> ('leads') - & Gt; onDelete ('waterfall');}); } // Clues Model class provides LeadsModel eloquent {secure $ table = 'leads'; Public Function Email () {Return $ this- & gt; There are many ('LeadDetailEmailsModel', 'lead_id', 'id'); }} // Key Extension Email Class LeadDetailEmail provides leads {secure $ table = 'lead_detail_email'; Public Function Lead () {Return $ this- & gt; Affiliation ('LeadsModel'); }}  

When I'm trying to add nested position to curious load, say

  $ qry = LeadsModel :: with ( Array ('email' = & gt; function ($ qr) {$ qr-> or where ('email', 'like', '% testname%');})); $ Res = $ qry- & gt; get receive (); Dd ($ race);  

It gives all records in the lead, I

  - & gt; Join ('lead_detail_emails', 'lead_detail_emails.lead_id', '=', 'leads.id');  

But it does not work well. Do I know what the problem is in the code?

Update question

How can I have nested status on email?

$ qry = LeadsModel :: with (array ('email' = & gt; Function ($ q) Usage ($ input) {$ q-> where ('email', 'like', '% {$ input}% ");} -> where (' email ', function Use ($ q) ($ input) {$ q-> ('email', 'like', "% {$ input}%");}); $ res = $ qry- & gt; Do ();

Comments