Home>

There is an export of applications Table 'Orders', Foreach enriches data from other tables, the problem is that it replaces the same data from other tables, and does not add what cause is the reason? I suspect that I do not correctly request a collection Here is the code

$ Orders= Order :: OrderBy ('ID', 'Desc') ->
Wheredate ('Order_Date', '2021-08-19') ->
get ();
    if ($ Orders->
Count ()) {
        Foreach ($ Orders AS $ Order) {
            /* Counterpart * /
            $ Counter= Countertegent :: Find ($ Order->
counter_agent_id);
            If (! $ Counter) {
                Continue;
            }
            /* Director */
            $ Director= Name :: Find ($ Counter->
director_name_id);
            If (! $ director) {
                Continue;
            }
            $ director_full_name= trim ($ director->
Last_Name). ' '.trim ($ Director->
FIRST_NAME);
            $ director_full_name.= '' .trim ($ Director->
middle_name);
            /* Agent * /
            $ Agent= Name :: Find ($ Order->
name_id);
            If (! $ Agent) {
                Continue;
            }
            $ agent_full_name= trim ($ agent->
Last_Name). ' '.trim ($ Agent->
middle_name);
            $ agent_full_name.= '' .trim ($ Agent->
FIRST_NAME);
            /* Contacts Contract * /
            $ Phone= Phone :: WHERE ('Agent_ID', '=', $ Counter->
id) ->
first ();
            $ email= email :: where ('agent_id', '=', $ counter->
id) ->
first ();
            $ REC_PHONE= '';
            if ($ Phone) {
                $ REC_PHONE= $ PHONE->
Phone;
            }
            $ REC_EMAIL= '';
            if ($ email) {
                $ REC_EMAIL= $ email->
email;
            }
            $ guarantee= 'execution';
            $ Status= 'Chernovik';
            $ Counter->
Name= Trim (Str_replace ('"', '&
quot; ', $ counter->
Name));
            $ CONTENT.= '". $ Order->
Order_date. '"," "$ Counter->
name. '","'. $ Counter->
Inn. '",';
            $ CONTENT.= '"'. $ director_full_name. '", "" $ REC_PHONE.' "," "$ REC_EMAIL. '", "" $ Counter->
Address. '",';
            $ CONTENT.= '". $ Order->
Amount. '","'. $ Order->
Bill. '",". $ Order->
law_id. '",';
            $ Content.= '"'. $ Guarantee. '", ". $ Order->
AUCTION_DATE. '","'. $ Order->
guarantee_Expires. '","'. $ Status. '"';
            $ content.= php_eol;
        }
    }

Can you give the actual and desired results?

nomnoms122021-08-22 21:30:10

Now I will throw off the picture, I get it allocated a user, this user has several applications, and one is displayed

zadrog2021-08-22 21:30:10

Are you sure that the user has several applications? If you can give, please, please, a small part of the database.

nomnoms122021-08-21 22:29:21

@ nomnoms12 threw off)

zadrog2021-08-21 23:41:55

"The problem is that the same data from other tables it replaces" what and where replaces? Perephrase the question.

E_K2021-08-22 00:56:02