NithApple
1 month ago
172
2
Laravel

Get Data from Database

Posted 1 month ago by NithApple

can you tell me why? i have created two functions to get data from database and there function select the same table just different status field but the first function getting object and second function getting array object

public function open(){ $lead = Lead::get()->where('status','Open')->toJson(JSON_PRETTY_PRINT); return response($lead, 200); }

public function close(){
    $lead = Lead::get()->where('status','Converted')->toJson(JSON_PRETTY_PRINT);
    return response($lead, 200);
}

result: public function open

{ "1": { "id": 10, "firstname": "admin", "lastname": "apple", "gender": "Male", } }

result : public function close

[ { "id": 8, "firstname": "Sasss", "lastname": "Seksss", "gender": "Male",

} ]

Please sign in or create an account to participate in this conversation.