Browse Source

toArray in SqlResultCollection

namespace
Alexander Demidov 9 years ago
parent
commit
5f6a454e6a
  1. 18
      Model/SqlResultCollection.php

18
Model/SqlResultCollection.php

@ -1,6 +1,8 @@
<?php namespace Majestic\Model; <?php namespace Majestic\Model;
class SqlResultCollection extends \ArrayIterator implements iSqlResultItems
use Illuminate\Support\Contracts\ArrayableInterface;
class SqlResultCollection extends \ArrayIterator implements iSqlResultItems, ArrayableInterface
{ {
private $items; private $items;
@ -42,4 +44,18 @@ class SqlResultCollection extends \ArrayIterator implements iSqlResultItems
$sql_result_provider = new SqlResultProvider($this->items); $sql_result_provider = new SqlResultProvider($this->items);
return $sql_result_provider->assoc($field, $assoc_as_array); return $sql_result_provider->assoc($field, $assoc_as_array);
} }
/**
* Get the collection of items as a plain array.
*
* @return array
*/
public function toArray()
{
return array_map(function($value)
{
return $value instanceof ArrayableInterface ? $value->toArray() : $value;
}, $this->items);
}
} }
Loading…
Cancel
Save