sjdaws / vocal

Extended functionality for Eloquent in Laravel 4 and 5
MIT License
44 stars 5 forks source link

(Eloquent\Model conflict) Rename hydrate function to something else (eg. hydrateModel) #5

Closed Edwin-Luijten closed 10 years ago

Edwin-Luijten commented 10 years ago

Because of a function naming collision, an exception is raised: Cannot make static method Illuminate\Database\Eloquent\Model::hydrate() non static in class LakeDawson\Vocal\Vocal

The Illuminate\Database\Eloquent\Model class now has a function hydrate:

<?php
/**
     * Create a collection of models from plain arrays.
     *
     * @param  array  $items
     * @param  string  $connection
     * @return \Illuminate\Database\Eloquent\Collection
     */
    public static function hydrate(array $items, $connection = null)
    {
        $collection = with($instance = new static)->newCollection();

        foreach ($items as $item)
        {
            $model = $instance->newFromBuilder($item);

            if ( ! is_null($connection))
            {
                $model->setConnection($connection);
            }

            $collection->push($model);
        }

        return $collection;
    }
sjdaws commented 10 years ago

Ah! Thanks for that, pull request merged 3767f9f85794f54019620b4c758cf8af971e3b0b and will push out 0.1.7 shortly.