public function setData($collection, $resource_name = '')
    {
        $this->collection = collect();

        if (!$this->resource_name) {
            $this->resource_name = empty($resource_name) ? 'undefined' : $resource_name;
        }

        $this->data = [];
        
        foreach ($collection as $item) {
            $this->collection->push(clone $item);
            $i = new Item($item, $this->resource_name);
            array_push($this->data, $i->getData());
        }
        $this->response['data'] = $this->data;
    }
public function setData($collection, $resource_name = '')
    {
        $this->collection = collect();

        if (!$this->resource_name) {
            $this->resource_name = empty($resource_name) ? 'undefined' : $resource_name;
        }

        $this->data = [];
        
        foreach ($collection as $item) {
            $this->collection->push(clone $item);
            $i = new Item($item, $this->resource_name);
            array_push($this->data, $i->getData());
        }
        $this->response['data'] = $this->data;
    }
public function setData ( $ collection , $ resource_name = '' ) { $ this -> collection = collect ( ) ; if ( ! $ this -> resource_name ) { $ this -> resource_name = empty ( $ resource_name ) ? 'undefined' : $ resource_name ; } $ this -> data = [ ] ; foreach ( $ collection as $ item ) { $ this -> collection -> push ( clone $ item ) ; $ i = new Item ( $ item , $ this -> resource_name ) ; array_push ( $ this -> data , $ i -> getData ( ) ) ; } $ this -> response [ 'data' ] = $ this -> data ; }
Set collection data

@param type $collection
@param string $resource_name
Set collection data