think\Collection::toArray PHP Method

toArray() public method

public toArray ( )
    public function toArray()
    {
        return array_map(function ($value) {
            return $value instanceof Model || $value instanceof self ? $value->toArray() : $value;
        }, $this->items);
    }

Usage Example

Ejemplo n.º 1
0
 public function toArray()
 {
     if ($this->paginator) {
         try {
             $total = $this->total();
         } catch (Exception $e) {
             $total = null;
         }
         return ['total' => $total, 'per_page' => $this->listRows(), 'current_page' => $this->currentPage(), 'data' => parent::toArray()];
     } else {
         return parent::toArray();
     }
 }