I have write that code but i want take an array of this, is this possible?
$results = DB::table('pages')->select('id', 'link')->orderBy('id', 'asc')->get();
To get laravel query builder result in array check this:
$results = DB::table('pages')->select('id', 'link')->orderBy('id', 'asc')->get()->toArray();
Or
If you prefer to use Query Builder instead of Eloquent here is the solutions
$results = DB::table('pages')->select('id', 'link')->orderBy('id', 'asc')->get();
First Solution
$array = (array) $result;
Second Solution
$array = get_object_vars($result);
Third Solution
$array = json_decode(json_encode($result), true);
hope it may help
You can see from the API docs that the get() function returns either a Collection or a Builder.
Laravel collections have the toArray() method (described in the docs) as shown below:
$collection = collect(['name' => 'Desk', 'price' => 200]);
$collection->toArray();
/*
[
['name' => 'Desk', 'price' => 200],
]
*/
Therefore, you can do the following:
$results = DB::table('pages')->select('id', 'link')->orderBy('id', 'asc')->get()->toArray();
dd(DB::table('pages')->select('id', 'link')->orderBy('id', 'asc')->get()); and take a screenshot, censoring sensitive info? It'd be good to see exactly what's being returned.