- hello,
i am on trouble while fetching data from another table. all goes ok , like relation , data but another table data only get 1 id
but i want all data where store forign key.
here is my code,
Heading
//controller
$reply_message = FamilyMessage::with('communitymessages')->where('resident_id', $request->resident_id)->where('id', $request->id)->latest('id')->get()->toArray();
and i got this answer
array:1 [▼
0 => array:9 [▼
"id" => 176
"community_id" => 25
"resident_id" => 4515
"name" => "romil"
"message" => "test 1"
"status" => 1
"created_at" => "2020-01-20 11:27:39"
"updated_at" => "2020-01-21 05:28:51"
"communitymessages" => array:10 [▼
"id" => 21
"user_id" => 3
"resident_id" => 4515
"community_id" => 25
"family_message_id" => 176
"name" => " romil "
"reply_msg" => "reply test 1"
"status" => 0
"created_at" => "2020-01-20 11:28:15"
"updated_at" => "2020-01-20 11:28:15"
]
]
]
see communitymessages only get 1 row, but i want all rows where store same forign key.
please help me.
i want answer like this
array:1 [▼
0 => array:9 [▼
"id" => 176
"community_id" => 25
"resident_id" => 4515
"name" => "romil"
"message" => "test 1"
"status" => 1
"created_at" => "2020-01-20 11:27:39"
"updated_at" => "2020-01-21 05:28:51"
"communitymessages" => array:10 [▼
"id" => 21
"user_id" => 3
"resident_id" => 4515
"community_id" => 25
"family_message_id" => 176
"name" => " romil "
"reply_msg" => "reply test 1"
"status" => 0
"created_at" => "2020-01-20 11:28:15"
"updated_at" => "2020-01-20 11:28:15"
],
"communitymessages" => array:10 [▼
"id" => 22
"user_id" => 3
"resident_id" => 4515
"community_id" => 25
"family_message_id" => 176
"name" => " romil "
"reply_msg" => "reply test 2"
"status" => 0
"created_at" => "2020-01-20 11:28:15"
"updated_at" => "2020-01-20 11:28:15"
],
"communitymessages" => array:10 [▼
"id" => 23
"user_id" => 3
"resident_id" => 4515
"community_id" => 25
"family_message_id" => 176
"name" => " romil "
"reply_msg" => "reply test 3"
"status" => 0
"created_at" => "2020-01-20 11:28:15"
"updated_at" => "2020-01-20 11:28:15"
]
]
]
i am on trouble while fetching data from another table. all goes ok , like relation , data but another table data only get 1 id but i want all data where store forign key. here is my code, i am on trouble while fetching data from another table. all goes ok , like relation , data but another table data only get 1 id but i want all data where store forign key. here is my code,
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire