SA__ SA__ - 1 month ago 7
JSON Question

php How to get it pure array from Eloquent Laravel

Here is my Query

$reminderData = Reminder::where('status', 1)->get()->toArray();


Here is my Result

[
{"id":1,"reminder_type":2,"reminder_name":"first","reminder_date":"2016-10-26"},
{"id":2,"reminder_type":2,"reminder_name":"second","reminder_date":"2016-10-26"},
{"id":3,"reminder_type":2,"reminder_name":"third","reminder_date":"2016-10-26"},
]


But i need like

[
["id":1,"reminder_type":2,"reminder_name":"first","reminder_date":"2016-10-26"],
["id":2,"reminder_type":2,"reminder_name":"second","reminder_date":"2016-10-26"],
["id":3,"reminder_type":2,"reminder_name":"third","reminder_date":"2016-10-26"],
]


How can i do this ?

Answer

It actually returns array of arrays. You you'll use dd() on both levels, you'll see an array data type.

Also, you can get only columns you need with ->get(['id', 'reminder_type', 'reminder_date'])